This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ManyToMany inverseJoinColumns side null fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ManyToMany inverseJoinColumns side null fields" Watch "ManyToMany inverseJoinColumns side null fields" New topic

ManyToMany inverseJoinColumns side null fields

Sharmila Punde
Ranch Hand

Joined: Dec 26, 2007
Posts: 133
Dear All,
Database table structure is as -

Please take a look at code which works fine -

I can see output of line #1 with list of 2 employees,
But somehow persistence provider do not initialize Employee.officeBranches , so the 'empsOfficeBranches'
on line #2 get initialized to null.
What is the problem with the above code? Why Employee.officeBranches does not get initialized
with list of OfficeBranch after en.refresh(ob) method call on line #0.


Regards, Sharmila.
We will have a future if we save Nature!
Will Myers
Ranch Hand

Joined: Aug 05, 2009
Posts: 319

Try adding fetch=FetchType.EAGER to the @ManyToMany annotations, the default is Lazy I think
Consider Paul's rocket mass heater.
subject: ManyToMany inverseJoinColumns side null fields
Similar Threads
One to One mapping in Hibernate 3
JPA (TopLink) @ManyToMany generates strange tables
Associated/ Child Pojo not getting saved with one to many
Hibernate Criteria Ambiguos
hbm without primary key