OPENJPA-132 : Fix bugs with using a field of type java.sql.Date/Time/Timestamp

as a single-field identity primary key.  Replaced "generationtype" test package
with "identity" test package and moved old identity generation tests to new
package, along with new test for java.sql.Date id fields.



git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@520522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2007-03-20 19:00:38 +00:00
parent 229f24547a
commit eb27482080
4 changed files with 12 additions and 2 deletions

View File

@ -1826,6 +1826,11 @@ public class PCEnhancer {
Object.class, null); Object.class, null);
if (!fieldManager && type != Object.class) if (!fieldManager && type != Object.class)
code.checkcast().setType(fmds[i].getDeclaredType()); 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 { } else {
code.invokevirtual().setMethod(oidType, "getId", code.invokevirtual().setMethod(oidType, "getId",
unwrapped, null); unwrapped, null);
@ -2023,6 +2028,8 @@ public class PCEnhancer {
addExtractObjectIdFieldValueCode(code, pk); addExtractObjectIdFieldValueCode(code, pk);
if (_meta.getObjectIdType() == ObjectId.class) if (_meta.getObjectIdType() == ObjectId.class)
args = new Class[]{ Class.class, Object.class }; args = new Class[]{ Class.class, Object.class };
else if (_meta.getObjectIdType() == Date.class)
args = new Class[]{ Class.class, Date.class };
else else
args = new Class[]{ Class.class, pk.getObjectIdFieldType() }; args = new Class[]{ Class.class, pk.getObjectIdFieldType() };
} }

View File

@ -241,6 +241,9 @@ public class ApplicationIds {
case JavaTypes.OBJECT: case JavaTypes.OBJECT:
return new ObjectId(cls, koid.getIdObject(), return new ObjectId(cls, koid.getIdObject(),
koid.hasSubclasses()); koid.hasSubclasses());
case JavaTypes.DATE:
return new DateId(cls, ((DateId) oid).getId(),
koid.hasSubclasses());
default: default:
throw new InternalException(); throw new InternalException();
} }

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.openjpa.persistence.generationtype; package org.apache.openjpa.persistence.identity;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.openjpa.persistence.generationtype; package org.apache.openjpa.persistence.identity;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;