permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes Many to one object is null??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Many to one object is null???" Watch "Many to one object is null???" New topic
Author

Many to one object is null???

Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Hi all,
Having a major (for me) hibernate issue. I think I have final got my head around it enough to use it, and then it goes and does soething I cant figure out.

I have the following mapping:


In my User class i have a UserRole object. When I do a find on the User, I am expecting hibernate to have populated the UserRole object (preferable with the correct user role) but it dosnt it, its null.

So, what am I doing wrong, why isint the parent object pulled in as I would expect. It seems to find the User object without me having to have "loaded" the user table.

Bit confused here.

Thanks
G
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Hibernate seems to load child (collections) into parent objects without any issue.....
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Hi,
Could the problem I am have be down to not having a many to one mapping in the parent tables mapping?

Thanks
G
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Many to one object is null???
 
Similar Threads
Hibernate Delete Problem
Hibernate inserting man-to-one fails
Hibernate mapping and versioning issues
Hibernate causing Concurrent Modification Exception
Hibernate Mapping (Many-To-One Association). Problem. This forum is my last hope.