Forums de discussion

Custom query: org.hibernate.MappingException: Unknown entity

thumbnail
Florencia Gadea, modifié il y a 11 années.

Custom query: org.hibernate.MappingException: Unknown entity

Regular Member Publications: 146 Date d'inscription: 27/03/12 Publications récentes
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, modifié il y a 11 années.

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

Regular Member Publications: 146 Date d'inscription: 27/03/12 Publications récentes
Anyone?

I've been trying to make this work for days, and I can't get any help.
thumbnail
Juan Gonzalez P, modifié il y a 11 années.

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

Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
Try changing all your

MessageSourceModelImpl

to

MessageSourceModel
thumbnail
Florencia Gadea, modifié il y a 11 années.

RE: Custom query: org.hibernate.MappingException: Unknown entity (Réponse)

Regular Member Publications: 146 Date d'inscription: 27/03/12 Publications récentes
I tested it and it never worked.

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

Thanks anyway.
thumbnail
Pugalendhi Radhakrishnan, modifié il y a 7 années.

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

New Member Publications: 14 Date d'inscription: 18/11/13 Publications récentes
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 .