Hi,
I am new to JPA. I have a question regarding OneToMany mapping.
For Eg: I have a Magazine which can have many Articles.
In RDBMS,
Magazine - int MagID, String MagName, Collection Articles
Articles - ArticleID(PrimaryKey), ArticleName, MagId (ForeignKey)
To model this in Java
I would have a Magazine class which contains an ArrayList of Articles.
But the above Java model doesnt persist properly unless I add the reference
of Magazine to Article class.
I had the following mapping to make it work.
In Magazine class
@OneToMany (cascade=CascadeType.ALL, mappedBy="magazine")
@OrderBy
private Collection<Article> articles;
In Article class
@ManyToOne
@JoinColumn(name="MagID", nullable=false)
private Magazine Mag;
Is there a way I can achieve this without adding a reference of Mag to
Article?
Thanks in advance..
Best Regards,
Srini
--
View this message in context:
http://n2.nabble.com/Regarding-oneToMany-mapping-tp1643457p1643457.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.