mirror of https://github.com/apache/openjpa.git
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:
parent
229f24547a
commit
eb27482080
|
@ -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() };
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
|
@ -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;
|
Loading…
Reference in New Issue