Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] none of the @OneToMany fields are being persisted in an @Embeddable class

Can you include the code you use to persist the object, and the log on finest
of the transaction.

Do any errors or warnings occur on startup?

It is odd to have a OneToMany in an Embeddable as they have no id, and note
that the embeddable is not mapping the ID column that is being used in the
join.

If you move the OneToMany to the parent, or change it to use a JoinTable
instead of a JoinColumn does it work?



Paul Harrison-8 wrote:
> 
> Hi,
> 
> I have a problem using eclipselink 2.2.0 in that none of the @OneToMany
> fields are being persisted in and @Embeddable class. The partial source is
> below with Container being the container class for the Emb class - The
> tables are created as I would expect, but on trying to persist a Container
> object none of Many objects are written to the database. Is this a bug or
> am I doing something wrong?
> 
> @Entity
> public class Container implements Serializable {
> 
>     @Id
>     @GeneratedValue
>     private int id;
>     private String incnt;
>     @Embedded
>     private Emb em;
> }
> 
> @Embeddable
> public class Emb implements Serializable {
> 
> 
>     protected String simple;
> 
>     @JoinColumn(name = "CONT_IDENTIFIER", referencedColumnName = "ID")
>     @OneToMany(cascade = PERSIST, orphanRemoval = false)
>     protected List<Many> lots;
> }
> 
> @Entity
> public class Many implements Serializable {
>         
> 	@Id
> 	@GeneratedValue
>         protected int id;
> 	protected String name;
> 	protected int other;
> 	
> }
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/none-of-the-%40OneToMany-fields-are-being-persisted-in-an-%40Embeddable-class-tp31851258p31902914.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top