Foros de discusión

using native SQL

thumbnail
asile elisa, modificado hace 13 años.

using native SQL

Regular Member Mensajes: 126 Fecha de incorporación: 17/02/10 Mensajes recientes
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 hace 13 años.

RE: using native SQL

Regular Member Mensajes: 126 Fecha de incorporación: 17/02/10 Mensajes recientes
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 hace 11 años.

RE: using native SQL

New Member Mensajes: 17 Fecha de incorporación: 24/03/11 Mensajes recientes
Should use BookImpl.class
thumbnail
Harish Kumar, modificado hace 11 años.

RE: using native SQL

Expert Mensajes: 483 Fecha de incorporación: 31/07/10 Mensajes recientes
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 hace 11 años.

RE: using native SQL

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
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.