[prev in list] [next in list] [prev in thread] [next in thread]
List: ojb-user
Subject: Persisting a HashMap of objects with composite primary keys
From: Laran Evans <lc278 () cornell ! edu>
Date: 2005-12-01 18:24:18
Message-ID: 30ec9fe20512011024i29fae022ybdb78e349f0fc679 () mail ! gmail ! com
[Download RAW message or body]
How would I persist class A below?
C and D have a composite primary key in the database.
The primary key for C is innermostOneKey and referenceToOutermostKey.
The primary key for D is innermostOneKey and referenceToOutermostKey.
My understanding is that with ManageableHashMap, when loading from the
database the key in the Map is set to the primary key. Clearly that
won't work with a composite key.
I'd really rather not use a reference table however if at all
possible. The other alternative is to use ManageableArrayLists instead
of Maps. This has other side-effects however which lead to a slightly
unclean API. I'd like to avoid that if possible, but will resort to it
if it is the simplest solution.
Is there any way to do this?
---
class A {
Map outermost;
}
class B {
Integer outermostKey;
Map innermostOne;
Map innermostTwo;
}
class C {
Integer innermostOneKey;
Integer outermostKey;
...
}
class D {
Integer innermostTwoKey;
Integer outermostKey;
...
}
class Main {
public static void main(String[] args) {
A a = new A();
B b = new B();
C c = new C();
D d = new D();
c.outerMostKey = b.outermostKey;
d.outerMostKey = b.outermostKey;
b.innermostOne.put(c.innermostOneKey, c);
b.innermostTwo.put(d.innermostTwoKey, d);
a.outermost.put(b.outermostKey, b);
...
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic