| Re: [eclipselink-users] Unidirectional @OneToMany: is it possiblewith not nullable foreign key? |
|
>It is not really so, card object could exist also without
transaction (for example it can be created just for authentication
purposes) and should be saved into separate DB table.
You can't have instances of the
same class sometimes to be saved in one table and other times saved in another
one in the same persistence unit - you have to have two different
classes.
The only real disadvantage to
embeddable I can see is inability to query - if that's important then make the
relation bidirectional.
The foreign key in
unidirectional OneToMany can't be non-nullable because (as opposed to Embedded
ElementCollection member)
the target entity may
be persisted (without source object existing).
em.getTransaction().begin();
Card card = new
Card(...);
em.persist(card);
em.getTransaction().commit();
|