openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dinkar Rao" <dinkar.d91411...@gmail.com>
Subject Re: Generic Id on MappedSupperclass
Date Sun, 04 Jan 2009 21:29:00 GMT
Hi,

I don't have a solution to your problem, but here is the cause of it:

In the parameterized type Identifiable, after type erasure, the
resulting type of id is the upper bound of the type parameter T. In
this case, the upper bound is Serializable. If you look at the
disassembled code for Identifiable, you will see id defined like this:

private Serializable id;

It is this id that is inherited by Group. And OpenJPA maps this to the
SQL type BLOB, which can't be used for primary keys.

The type argument Long, or any of the subclasses of Serializable, that
is passed into the instantiation of Identifiable (in the definition of
Group) has no effect on the compile-time type of id, which will always
be Serializable. All instantiations of the parameterized type
Identifiable have this same type for the id field and all subclasses
of Identifiable will inherit this id field.

You mentioned that this works with Hibernate with the standard JPA
annotations, but there must be other information that is somehow being
passed to Hibernate for this to work as expected.

Thanks,
Dinkar

Mime
View raw message