This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate generating wrong query 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 "Hibernate generating wrong query" Watch "Hibernate generating wrong query" New topic
Author

Hibernate generating wrong query

Pranjal Swarup
Greenhorn

Joined: Dec 02, 2011
Posts: 2
Hi,

I am getting the following exception

org.hibernate.exception.SQLGrammarException: could not load an entity: [com.dao.Account#121]

Sql ssyntax generated is:

Hibernate:
select
account0_.employeeId as employeeId0_0_,
account0_.id as id0_0_,
account0_.firstname as firstname0_0_,
account0_.lastname as lastname0_0_,
account0_.type as type0_0_,
account0_.managerId as managerId0_0_
from
laps.user.account account0_
where
account0_.employeeId=?

problem is it appends a user between laps.account, user is another table that I excluded while generating DAOs, any idea?

thanks,
pranjal
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Hello, Pranjal Swarup

Welcome to javaranch.

How are you doing your search in the database?


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

user is another table that I excluded while generating DAOs, any idea?

How you do this? And what mappings you have for this? You may need to tell more details (TellTheDetails).


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Pranjal Swarup
Greenhorn

Joined: Dec 02, 2011
Posts: 2
Thanks the problem has been resolved, it was mainly an error because I had set both database name and initial catalog field.
 
Consider Paul's rocket mass heater.
 
subject: Hibernate generating wrong query
 
Similar Threads
Hibernate 3: java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value
Hibernate Many to ManyMapping
Hibernate POJO class grtter method
need help in updating data using hibernate hql
Data is not properly export in the XML file