Here is the solution.......
DynamicQuery dynaQuery = DynamicQueryFactoryUtil
.forClass(User_Customer.class);
.forClass(User_Customer.class);
dynaQuery.setProjection(ProjectionFactoryUtil
.property("primaryKey.id_customer");
.property("primaryKey.id_customer");
dynaQuery.add(RestrictionsFactoryUtil.eq("primaryKey.id_userId", userId));
List<Integer> customerIds = new ArrayList<Integer>();
customerIds = (List<Integer>)user_CustomerPersistence.findWithDynamicQuery(dynaQuery);
customerIds = (List<Integer>)user_CustomerPersistence.findWithDynamicQuery(dynaQuery);
The case is...you have a composite key and whenever you try using it like this
dynaQuery.setProjection(ProjectionFactoryUtil.property("id_customer");
You are getting an exception, something like this:-
06:34:05,450 ERROR [http-bio-8080-exec-88][BasePersistenceImpl:186]
Caught unexpected exception org.hibernate.QueryException
com.liferay.portal.kernel.exception.SystemException:
org.hibernate.QueryException: could not resolve property: userId of:
com.test.model.impl.User_CustomerImpl
Use "primaryKey.columnName" instead of "columnName"
No comments:
Post a Comment