File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes node to traverse cannot be null! - problem with a simple one to many query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "node to traverse cannot be null! - problem with a simple one to many query" Watch "node to traverse cannot be null! - problem with a simple one to many query" New topic
Author

node to traverse cannot be null! - problem with a simple one to many query

Ray Clark
Ranch Hand

Joined: Aug 16, 2012
Posts: 52
I had 2 tables set up without any relationship specified in the objects and the query worked fine. I changed the objects to specify the one to many relationship and now I get the error "node to traverse cannot be null!".

Here is a snippet of the domain objects:

These are two methods from the DAO. The first method is the one that worked fine before adding the one to many relationship.

The DAO methods are actually being called from a JUnit test. I wouldn't think that would be a problem though.

I'm guessing that I have something wrong in my domain classes. Any ideas?

Thank you for your time.
Ray
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Please include the full exception and stack trace.


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Ray Clark
Ranch Hand

Joined: Aug 16, 2012
Posts: 52
Thank you for the reply.

After some trial and error I was finally able to get it to work. To keep this short I will post only what I had to change.



As you can see I had my OneToMany and my JoinColumn annotations set up incorrectly. (New to JPA/Hibernate)

My question now is, does the OneToMany require the variable to be a Set/HashSet? Can it be a List/ArrayList?

Thank You,
Ray
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: node to traverse cannot be null! - problem with a simple one to many query