Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
wei tang
DynamicQuery can not work
13 dicembre 2012 22.32
Risposta

wei tang

Punteggio: Junior Member

Messaggi: 36

Data di Iscrizione: 3 dicembre 2012

Messaggi recenti

I use User.class in my DynamicQuery, but it seems doesn't work!
Code:

DynamicQuery dquery = DynamicQueryFactoryUtil.forClass(GXSaleRecord.class, "record",PortalClassLoaderUtil.getClassLoader());
DynamicQuery cquery = DynamicQueryFactoryUtil.forClass(User.class,"user",PortalClassLoaderUtil.getClassLoader());
cquery.add(PropertyFactoryUtil.forName("user.firstName").like("%".concat(ticketName).concat("%")))
.setProjection(ProjectionFactoryUtil.property("primaryKey.userId"));
dquery.add(PropertyFactoryUtil.forName("record.ticketUserId").in(cquery));


PS:How to fix?


Exception:
14:21:26,996 ERROR [http-bio-8080-exec-49][render_portlet_jsp:154] com.liferay.portal.kernel.exception.SystemException: org.hibernate.MappingException: Unknown entity: com.liferay.portal.model.impl.UserImpl
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:193)
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.findWithDynamicQuery(BasePersistenceImpl.java:142)
at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:52)
at com.gx.db.service.base.GXSaleRecordLocalServiceBaseImpl.dynamicQuery(GXSaleRecordLocalServiceBaseImpl.java:165)
at com.gx.db.service.impl.GXSaleRecordLocalServiceImpl.findRawByAllOnAndOperator(GXSaleRecordLocalServiceImpl.java:245)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
at com.liferay.portal.dao.jdbc.aop.DynamicDataSourceTransactionInterceptor.invoke(DynamicDataSourceTransactionInterceptor.java:44)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
Rishi Dev Gupta
RE: DynamicQuery can not work
15 dicembre 2012 2.38
Risposta

Rishi Dev Gupta

Punteggio: Expert

Messaggi: 255

Data di Iscrizione: 23 novembre 2008

Messaggi recenti

Can you provide more details about the environment you are working in?

Whats ".setProjection(ProjectionFactoryUtil.property("primaryKey.userId"));", it should be user.userId intead fo primaryKey.userId.
Jelmer Kuperus
RE: DynamicQuery can not work
15 dicembre 2012 2.59
Risposta

Jelmer Kuperus

Punteggio: Liferay Legend

Messaggi: 1192

Data di Iscrizione: 10 marzo 2010

Messaggi recenti

Try doing

1.setProjection(ProjectionFactoryUtil.property("user.userId"));


instead of

1.setProjection(ProjectionFactoryUtil.property("primaryKey.userId"));