File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Getting incorrect values from SQL query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting incorrect values from SQL query" Watch "Getting incorrect values from SQL query" New topic

Getting incorrect values from SQL query

Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

Hi Guys

I'm faced with a Hibernate problem which makes absolutely no sense. I have a fairly large query which joins a whole bunch of tables with outer joins. Among others, it selects a number of boolean fields. Whereas it looks like all of the other fields are populated, the object array returned by my query contains a null value for one of the boolean fields.

I ran Netbeans in debug mode, and I copied the query and executed it in my MySQL query browser immediately before it's executed by the entity manager. In MySQL, I get the expected result (i.e. a valid boolean value in that particular field). Any thoughts on why the query works in the query browser but not in my Java code? I'm stumped.

Thanks for your help.


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Is your booleans attributes as classes? or primitives?

I do not know if this is the problem, is just a thought....

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

Hi Hebert

Thank you for your response. All of my boolean fields are primitives.
abani patra
Ranch Hand

Joined: Oct 11, 2011
Posts: 70
I think you should use many-to-one ,many-to-many,one-to-one,one-to-many relation rather using join in query.
I agree. Here's the link:
subject: Getting incorrect values from SQL query
It's not a secret anymore!