Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Florencia Gadea
Custom query: org.hibernate.MappingException: Unknown entity
November 23, 2012 3:55 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 146

Join Date: March 27, 2012

Recent Posts

Hi Everyone!

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

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

Here is the code:

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


Can you tell me what is wrong here?

TIA,

Flor.
Florencia Gadea
RE: Custom query: org.hibernate.MappingException: Unknown entity
November 23, 2012 3:56 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 146

Join Date: March 27, 2012

Recent Posts

Anyone?

I've been trying to make this work for days, and I can't get any help.
Juan Gonzalez
RE: Custom query: org.hibernate.MappingException: Unknown entity
November 23, 2012 10:45 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2300

Join Date: October 28, 2008

Recent Posts

Try changing all your

MessageSourceModelImpl

to

MessageSourceModel
Florencia Gadea
RE: Custom query: org.hibernate.MappingException: Unknown entity
December 4, 2012 5:47 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 146

Join Date: March 27, 2012

Recent Posts

I tested it and it never worked.

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

Thanks anyway.