Fórum

using native SQL

thumbnail
asile elisa, modificado 13 Anos atrás.

using native SQL

Regular Member Postagens: 126 Data de Entrada: 17/02/10 Postagens Recentes
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:

session.createSQLQuery("SELECT * FROM Book").addEntity(Book.class).list();

here is the exception:

org.hibernate.MappingException: Unknown entity: com.ext.portlet.library.model.Book


thanks in advance.
thumbnail
asile elisa, modificado 13 Anos atrás.

RE: using native SQL

Regular Member Postagens: 126 Data de Entrada: 17/02/10 Postagens Recentes
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.
thumbnail
Zhao Jin, modificado 11 Anos atrás.

RE: using native SQL

New Member Postagens: 17 Data de Entrada: 24/03/11 Postagens Recentes
Should use BookImpl.class
thumbnail
Harish Kumar, modificado 11 Anos atrás.

RE: using native SQL

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
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.
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: using native SQL

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
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.