Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
asile elisa
using native SQL
June 18, 2010 8:00 AM
Answer

asile elisa

Rank: Regular Member

Posts: 126

Join Date: February 17, 2010

Recent Posts

hi everyone,

I want tp use native SQL but even a simple query did not work and I got an exception
here is the Query:
1
2session.createSQLQuery("SELECT * FROM Book").addEntity(Book.class).list();

here is the exception:
1
2org.hibernate.MappingException: Unknown entity: com.ext.portlet.library.model.Book


thanks in advance.
asile elisa
RE: using native SQL
June 21, 2010 8:50 PM
Answer

asile elisa

Rank: Regular Member

Posts: 126

Join Date: February 17, 2010

Recent Posts

hi,

I can use native SQL directly in my JAVA class right?
it is not necessary to define my queries in xml files like what is shown in this article:
custom query
right??

thanks.
Neil Jin
RE: using native SQL
October 19, 2012 3:14 AM
Answer

Neil Jin

LIFERAY STAFF

Rank: New Member

Posts: 7

Join Date: March 23, 2011

Recent Posts

Should use BookImpl.class
Harish Kumar
RE: using native SQL
October 20, 2012 7:27 AM
Answer

Harish Kumar

Rank: Expert

Posts: 473

Join Date: July 31, 2010

Recent Posts

You cant use native sql directly in your java class.
hibernate session wont be available there. You should follow the same link for custom query, you have posted.
Hitoshi Ozawa
RE: using native SQL
October 21, 2012 3:44 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Is there some reason to why you would want to use sql directly? Liferay sometimes changes fields and interfaces and writing sql directly would make maintenance more difficult.