This content has been marked as final.
Show 3 replies
-
1. Re: Persisting an embedded object that contains a collection
epbernard Apr 7, 2005 4:07 PM (in response to ceracm)This is not supported by the EJB3 spec. But the preview 5 should allow you to write something like that
@Embeddable(access=AccessType.FIELD) class Bar { @OneToMany @JoinColumn(name="foo_id") private Collection<Baz> baz }
Note that this kind of mapping is not recommanded. Use a join table for such unidirectional one to many. -
2. Re: Persisting an embedded object that contains a collection
ceracm Apr 7, 2005 4:26 PM (in response to ceracm)"epbernard" wrote:
This is not supported by the EJB3 spec. But the preview 5 should allow you to write something like that@Embeddable(access=AccessType.FIELD) class Bar { @OneToMany @JoinColumn(name="foo_id") private Collection<Baz> baz }
Note that this kind of mapping is not recommanded. Use a join table for such unidirectional one to many.
Thanks for the suggestion.
Is this this explicitly disallowed in the EJB3 spec?
I couldn't really see anything.
Please could you explain why you recommend a join table instead of a foreign key mapping. -
3. Re: Persisting an embedded object that contains a collection
epbernard Apr 7, 2005 7:17 PM (in response to ceracm)"ceracm" wrote:
Is this this explicitly disallowed in the EJB3 spec?
I couldn't really see anything.
Please could you explain why you recommend a join table instead of a foreign key mapping.
The spec restrict the allowed mapping annotations in a embeddable object AFAIR.
99% of the @OneToMany cases should use a bidirectional mapping at the object level. If for some good reasons it is explicitly unwanted, then these reasons should encourage you to decouple the 2 entities (from a DB POV) through a join table.