掲示板

using native SQL

thumbnail
13年前 に asile elisa によって更新されました。

using native SQL

Regular Member 投稿: 126 参加年月日: 10/02/17 最新の投稿
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
13年前 に asile elisa によって更新されました。

RE: using native SQL

Regular Member 投稿: 126 参加年月日: 10/02/17 最新の投稿
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
11年前 に Zhao Jin によって更新されました。

RE: using native SQL

New Member 投稿: 17 参加年月日: 11/03/24 最新の投稿
Should use BookImpl.class
thumbnail
11年前 に Harish Kumar によって更新されました。

RE: using native SQL

Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
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
11年前 に Hitoshi Ozawa によって更新されました。

RE: using native SQL

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
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.