Foros de discusión

Custom query: org.hibernate.MappingException: Unknown entity

thumbnail
Florencia Gadea, modificado hace 11 años.

Custom query: org.hibernate.MappingException: Unknown entity

Regular Member Mensajes: 146 Fecha de incorporación: 27/03/12 Mensajes recientes
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 hace 11 años.

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

Regular Member Mensajes: 146 Fecha de incorporación: 27/03/12 Mensajes recientes
Anyone?

I've been trying to make this work for days, and I can't get any help.
thumbnail
Juan Gonzalez P, modificado hace 11 años.

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

Liferay Legend Mensajes: 3089 Fecha de incorporación: 28/10/08 Mensajes recientes
Try changing all your

MessageSourceModelImpl

to

MessageSourceModel
thumbnail
Florencia Gadea, modificado hace 11 años.

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

Regular Member Mensajes: 146 Fecha de incorporación: 27/03/12 Mensajes recientes
I tested it and it never worked.

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

Thanks anyway.
thumbnail
Pugalendhi Radhakrishnan, modificado hace 7 años.

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

New Member Mensajes: 14 Fecha de incorporación: 18/11/13 Mensajes recientes
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 .