0

Hibernate session is generating query with table name in Lowercase for example:

type = Employee.class but table is EMPLOYEE

but query is * from Emloyee where *

And because of this SQL exception of table doesnt exist!!

result = session.createCriteria(type).add(Restrictions.eq("Id", Id)).list();

Thanks in advance!!

adroit
  • 31
  • 5
  • And have you told Hibernate what the table name was? How comes the name is case-sensitive? Why do that? – JB Nizet Nov 23 '14 at 08:38
  • Yes I have done this ....... final Class type = abc.xyz.Employee.class; – adroit Nov 23 '14 at 08:43
  • That doesn't answer any of my questions. How can Hibernate know that the table name is EMPLOYEE? Why is the name case-sensitive? – JB Nizet Nov 23 '14 at 08:44
  • via my POJO isnt it? I am new to hibernate. Can you make me understand what is needed to tell hibernate. – adroit Nov 23 '14 at 08:45
  • And the code of the POJO is? Is there anything in that code that tells Hibernate "hey, my class is Employee, but the corresponding table name is EMPLOYEE, not Employee"? – JB Nizet Nov 23 '14 at 08:47
  • Actually in my pojo @Table(name="COMPONENT" is not written that is why I am confused too. But when I insert data it does insert correctly. the problem is when I am trying to read. and Pojo is not created by me its legacy code. – adroit Nov 23 '14 at 08:50
  • This is extremely confusing. Post the code of the entity, the code you're executing, and the complete stack trace of the exception you get. – JB Nizet Nov 23 '14 at 08:53

1 Answers1

0

SQL is case insensitive so these two selects are equivalent:

select * from Emloyee where id = 1
SELECT * FROM EMLOYEE WHERE ID = 1

Make sure Hibernate doesn't attempt to select against the PUBLIC schema while your tables are located in a different schema Hibernate is not aware of.

Community
  • 1
  • 1
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911