diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index a6222112b..da30e90ee 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -1826,6 +1826,11 @@ public class PCEnhancer { Object.class, null); if (!fieldManager && type != Object.class) code.checkcast().setType(fmds[i].getDeclaredType()); + } else if (oidType == DateId.class) { + code.invokevirtual().setMethod(oidType, "getId", + Date.class, null); + if (!fieldManager && type != Date.class) + code.checkcast().setType(fmds[i].getDeclaredType()); } else { code.invokevirtual().setMethod(oidType, "getId", unwrapped, null); @@ -2023,6 +2028,8 @@ public class PCEnhancer { addExtractObjectIdFieldValueCode(code, pk); if (_meta.getObjectIdType() == ObjectId.class) args = new Class[]{ Class.class, Object.class }; + else if (_meta.getObjectIdType() == Date.class) + args = new Class[]{ Class.class, Date.class }; else args = new Class[]{ Class.class, pk.getObjectIdFieldType() }; } diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java b/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java index 1c6dd431d..7716a870f 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java @@ -241,6 +241,9 @@ public class ApplicationIds { case JavaTypes.OBJECT: return new ObjectId(cls, koid.getIdObject(), koid.hasSubclasses()); + case JavaTypes.DATE: + return new DateId(cls, ((DateId) oid).getId(), + koid.hasSubclasses()); default: throw new InternalException(); } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/IdentityGenerationType.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/IdentityGenerationType.java similarity index 96% rename from openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/IdentityGenerationType.java rename to openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/IdentityGenerationType.java index 12accdff9..ee64d696d 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/IdentityGenerationType.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/IdentityGenerationType.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.openjpa.persistence.generationtype; +package org.apache.openjpa.persistence.identity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java similarity index 98% rename from openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java rename to openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java index df9de20bd..826202068 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.openjpa.persistence.generationtype; +package org.apache.openjpa.persistence.identity; import java.util.HashMap; import java.util.List;