-
Type:
Bug
-
Status: Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 5.6.0-HF10
-
Fix Version/s: 5.5.0-HF18, 5.6.0-HF15, 5.7.1
-
Component/s: Core VCS
-
Environment:PostgreSQL (Linux Debian)
-
Tags:
In a directory with an auto-incremented id field, sometimes at creation time an exception is returned, because PostgreSQL actually returns the wrong column value instead of the auto-generated one.
Error exception:
Caused by: org.nuxeo.ecm.directory.DirectoryException: createEntry failed at org.nuxeo.ecm.directory.sql.SQLSession.createEntry(SQLSession.java:261) at org.easysoa.registry.integration.EndpointStateServiceImpl.createIndicator(EndpointStateServiceImpl.java:102) at org.easysoa.registry.integration.EndpointStateServiceImpl.createSlaOlaIndicators(EndpointStateServiceImpl.java:71) ... 71 more Caused by: org.postgresql.util.PSQLException: Bad value for type long : OLA TdrWebService at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.java:2776) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:1999) at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:228) at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:228) at org.nuxeo.ecm.core.storage.sql.jdbc.dialect.DialectPostgreSQL.getFromResultSet(DialectPostgreSQL.java:298) at org.nuxeo.ecm.core.storage.sql.jdbc.db.Column.getFromResultSet(Column.java:215) at org.nuxeo.ecm.directory.sql.SQLSession.createEntry(SQLSession.java:255) ... 73 more
See similar problem in hibernate http://www.postgresql.org/message-id/flat/4D905F65.4030207@visitlondon.com#4D905F65.4030207@visitlondon.com
The solution is to call prepareStatement and pass it explicitly the columns we want returned, instead of just Statement.RETURN_GENERATED_KEYS (which the PostgreSQL JDBC driver interprets as adding RETURNING * to the query, which has the wrong behavior if the first column is not the id).
- depends on
-
NXP-7124 Make SQL directories with auto-incremented id field robust in multi-threaded scenarios
-
- Resolved
-