jQuery in Action, 2nd edition*
The moose likes Object Relational Mapping and the fly likes Simple native SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Simple native SQL" Watch "Simple native SQL" New topic
Author

Simple native SQL

S Setty
Greenhorn

Joined: Sep 08, 2008
Posts: 16
Can you help me to find what i am doing wrong.
I can't seem to get this working.

Query simpleQuery = session.createSQLQuery("select LEGACY_ACCT_IN as legacyIndicator FROM DB2.ACCOUNT_DETAILS WHERE ACCESS_MEDIUM_NO = :acctNum").addEntity(SimpleVO.class);

simpleQuery.setString("acctNum", "4889");

List lst = simpleQuery.list();

Exception data: org.hibernate.MappingException: Unknown entity: common.stmt.business.domain.SimpleVO

Thanks
Santosh
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Have you declared the SimpleVO class in the Hibernate configuration file?
S Setty
Greenhorn

Joined: Sep 08, 2008
Posts: 16
Thanks for replying.

No i do not have anything in the hibernate config file. I was thinking addEntity method will register.

Do you have an example or syntax handy?

Appreciate your help.

Thanks
Santosh
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
This is very important. Below is an example.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Simple native SQL