Fórum

Custom query: org.hibernate.MappingException: Unknown entity

thumbnail
Florencia Gadea, modificado 11 Anos atrás.

Custom query: org.hibernate.MappingException: Unknown entity

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
Hi Everyone!

When I try to execute a custom query I get this exception:

com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.MappingException: Unknown entity: com.rcs.service.model.impl.MessageSourceImpl

Here is the code:


String sql = "SELECT DISTINCT resourcekey, resourcelocale, resourcevalue, resourcebundle from resourceEditor_MessageSource";		
setSessionFactory((SessionFactory)PortalBeanLocatorUtil.getBeanLocator().locate(MessageSourceModelImpl.SESSION_FACTORY));
Session session = openSession();
SQLQuery q = session.createSQLQuery(sql);
q.setCacheable(false);
q.addEntity(MessageSourceModelImpl.TABLE_NAME, MessageSourceImpl.class);
List<messagesource> result = ( List<messagesource> ) QueryUtil.list(q, getDialect(), start, end);</messagesource></messagesource>


Can you tell me what is wrong here?

TIA,

Flor.
thumbnail
Florencia Gadea, modificado 11 Anos atrás.

RE: Custom query: org.hibernate.MappingException: Unknown entity

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
Anyone?

I've been trying to make this work for days, and I can't get any help.
thumbnail
Juan Gonzalez P, modificado 11 Anos atrás.

RE: Custom query: org.hibernate.MappingException: Unknown entity

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
Try changing all your

MessageSourceModelImpl

to

MessageSourceModel
thumbnail
Florencia Gadea, modificado 11 Anos atrás.

RE: Custom query: org.hibernate.MappingException: Unknown entity (Resposta)

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
I tested it and it never worked.

I ended up getting the same results using a dynamic query.

Thanks anyway.
thumbnail
Pugalendhi Radhakrishnan, modificado 7 Anos atrás.

RE: Custom query: org.hibernate.MappingException: Unknown entity

New Member Postagens: 14 Data de Entrada: 18/11/13 Postagens Recentes
Florencia Gadea:
Hi Everyone!

When I try to execute a custom query I get this exception:

com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.MappingException: Unknown entity: com.rcs.service.model.impl.MessageSourceImpl

Here is the code:


String sql = "SELECT DISTINCT resourcekey, resourcelocale, resourcevalue, resourcebundle from resourceEditor_MessageSource";		
setSessionFactory((SessionFactory)PortalBeanLocatorUtil.getBeanLocator().locate(MessageSourceModelImpl.SESSION_FACTORY));
Session session = openSession();
SQLQuery q = session.createSQLQuery(sql);
q.setCacheable(false);
q.addEntity(MessageSourceModelImpl.TABLE_NAME, MessageSourceImpl.class);
List<messagesource> result = ( List<messagesource> ) QueryUtil.list(q, getDialect(), start, end);</messagesource></messagesource>


Can you tell me what is wrong here?

TIA,

Flor.



Hi,
I know its very old thread but it might helpful to some one. Remove setting session factory for the custom entity's. Only out of box entities requires session factory .