Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ManyToMany inverseJoinColumns side null fields

 
Sharmila Punde
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks

 
Will Myers
Ranch Hand
Posts: 396
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding fetch=FetchType.EAGER to the @ManyToMany annotations, the default is Lazy I think
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!