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 created hibernate SQL confusing 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 "created hibernate SQL confusing" Watch "created hibernate SQL confusing" New topic
Author

created hibernate SQL confusing

Scott Stephens
Greenhorn

Joined: Jun 25, 2011
Posts: 23

When I use the following with an embedded Derby Database:



Hibernate creates the following SQL Statement:

Hibernate:


however, when I use this



Hibernate generates

Hibernate:
select
*
from
PERSOAPP.PERSONAL
where
PERSON_ID =1

Here is my class mapping :

Maybe someone has some tips!
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Welcome to ORM land. In your first example, Hibernate "knows" what it wants and generates SQL accordingly.
In the second you are bypassing Hibernate with native SQL so it basically does what you told it.

WP
Scott Stephens
Greenhorn

Joined: Jun 25, 2011
Posts: 23

Thanks. The "?" seems funny. Both snippets, however, return an object!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: created hibernate SQL confusing
 
Similar Threads
XDoclet does not generate Interfaces
Help with mapping set - Hibernate
DATABASE ERROR: java.sql.SQLException: Invalid argument(s) in call
Hibernate Collections - have lots of null elements aswell as my objects
Need help in using tags for below code