Wednesday 21 August 2013

Set JDK in Ubuntu (LINUX)

Run the following commands in your terminal if you have the tar.gz

1. tar -xvf jdk-7u21-linux-i586.tar.gz

2. sudo mv ./jdk1.7.0_21 /usr/lib/jvm/jdk1.7.0_21

3. sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_21/bin/java" 1

4. sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_21/bin/javac" 1

5. sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_21/bin/javaws" 1

6. sudo chmod a+x /usr/bin/java

7. sudo chmod a+x /usr/bin/javac

8. sudo chmod a+x /usr/bin/javaws

9. sudo chown -R root:root /usr/lib/jvm/jdk1.7.0_21

10.sudo update-alternatives --config java

11.export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21/

12.export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_21/bin

Sunday 11 August 2013

While using Dynamic Query getting "QueryException: could not resolve property"

Here is the solution.......

DynamicQuery dynaQuery = DynamicQueryFactoryUtil
                .forClass(User_Customer.class);
dynaQuery.setProjection(ProjectionFactoryUtil
.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);


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"