Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0
-
None
-
MySQL 5, 3.1 and 5.0 drivers
Description
java class of a DB-generated PK turns out to be undefined and generally not matching the type of column it is used for. E.g. for a JDBC int column, the default Java mapping is java.lang.Integer. When a generated key is configured for this column all db's return different values:
MySQL 5/Connector J 3.1.13 BigInteger
MySQL 5/Connector J 5.0.6 Long
Derby 10.2 BigDecimal
To be fair JDBC spec does not specify what should be returned, so the vendors are doing what they want.
This causes a number of problems in Cayenne. One specific exception - although we've hacked ObjectId comparison algorithm to unwrap the numbers and compare their numeric values, IncrementalFaultList compares DataRows and fails to match Objects against the id datarows:
/-- Encapsulated exception ------------\
org.apache.cayenne.CayenneRuntimeException: [v.3.0-SNAPSHOT Jun 28 2007 08:48:22] Can't find id for
at org.apache.cayenne.access.IncrementalFaultList$IncrementalListHelper.updateWithResolvedObjectInRange(IncrementalFaultList.java:779)
at org.apache.cayenne.access.IncrementalFaultList.resolveInterval(IncrementalFaultList.java:427)
at org.apache.cayenne.access.IncrementalFaultList.get(IncrementalFaultList.java:613)
I think we need to explicitly pass the Java type we expect for the ID inside the BatchAction