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 Getting All Records in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting All Records in Hibernate" Watch "Getting All Records in Hibernate" New topic
Author

Getting All Records in Hibernate

Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
I am using MySQL. For some reason, I can't get all records from a 2 tables in Hibernate.

I have tried this:


And this is not working. I am sure that my POJO and Mapping file are good since I was able to query on the same table but with "Restrictions". So this is working:


But this is NOT working:

[ June 17, 2007: Message edited by: Jazzy Jaz ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Jazzy Jaz",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
Im sorry. Made the correction.

Can anybody help me with the problem above?

Thank you in advance!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm not sure I understand your problem. You want to read all of the records for a table?

When you describe 'working' and 'not working', what do you mean?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

And just out of curiosity, you have

Query q = session.createQuery("from ReviewTO");

So you are creating a Query object, but where are you running that query. I am assuming that you called execute or list methods to get the resultset.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
Yes, I want to get all the records in a table. Code below is not returning any results but instead an error.



I mean by not working is, it spit out some errors like this:

org.hibernate.exception.GenericJDBCException: could not execute query

Thanks again!

[ June 17, 2007: Message edited by: Jazzy Sanchez ]
[ June 17, 2007: Message edited by: Jazzy Sanchez ]
Halcon Guatemala
Ranch Hand

Joined: Sep 06, 2006
Posts: 57
Hi Jazzy, could you post your entire trace... Is Hibernate generating a valid query You can run in another place.

Thanks


"La verdadera sabidur´┐Ża viene del temor de Dios"
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
Here's the error:

Exception in thread "main" java.lang.NullPointerException
at st.wais.to.Test.getAllReviews(Test.java:30)
at st.wais.to.Test.main(Test.java:17)ReviewDAO: org.hibernate.exception.GenericJDBCException: could not execute query

Thanks for the help!
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
Solved! It is a data integrity problem. The data being parse is not the type that's expected.

Thanks anyway!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting All Records in Hibernate
 
Similar Threads
isNotNull & isNotEmpty Hibernate
Problem in Query By Example (Hibernate)
Performance Issue in Hibernate?
Need Hibernate Criteria help.
Caseinsensitive Search Hibernate API