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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to