Foren

Issue with CounterLocalService of Liferay

thumbnail
Subhasis Roy, geändert vor 6 Jahren.

Issue with CounterLocalService of Liferay

Expert Beiträge: 275 Beitrittsdatum: 20.01.12 Neueste Beiträge
Hi,

I am facing issue with adding a row in the table. The issue is with primary key genration using CounterLocalService of Liferay.
.
I can see the "MYDETAILS" model file entry in the Liferay counter table with CURRENTID column value as 200.

But the problem is the primary key column in the "MYDETAILS" table is not getting auto incremented in liferay code.

Code used:
long pK = CounterLocalServiceUtil.increment(MyDetails.class.getName());
MyDetails myDetails = MyDetailsLocalServiceUtil.createMyDetails(pK);

Inside "createMyDetails" method I am adding a row in the table.
I can see the following error in the log file.

Error in Log:
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (MY_TEST_SCHEMA.PK_MYDETAILS) violated_ [Sanitized]
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10070)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:213)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 166 more
10:58:14,501 ERROR [http-bio-8080-exec-15][ClpSerializer:1670] java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException
java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at com.liferay.portal.kernel.util.ClassResolverUtil.resolve(ClassResolverUtil.java:29)
at com.liferay.portal.kernel.util.ClassLoaderObjectInputStream.resolveClass(ClassLoaderObjectInputStream.java:43)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
thumbnail
Suresh Nimmakayala, geändert vor 6 Jahren.

RE: Issue with CounterLocalService of Liferay

Liferay Master Beiträge: 690 Beitrittsdatum: 18.08.04 Neueste Beiträge
just try and see how it goes
long pK = 0L;
MyDetails myDetails =null;

try {
pK = CounterLocalServiceUtil.increment();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myDetails = MyDetailsLocalServiceUtil.createMyDetails(pK);
myDetails .set...... etc