| Assume the following code:
@MappedSuperclass
public abstract class AbstractEntity<PK extends Serializable> {
private @Id @GeneratedValue PK id;
}
@Entity
public class ConcreteEntity extends AbstractEntity<Long> { }
Bootstrapping an EntityManager for those types and trying to look up the type of the identifier property for ConcreteEntity returns Serializable instead of Long.
Metamodel metamodel = em.getMetamodel();
assertThat(metamodel.entity(ConcreteEntity.class).getIdType(), is(typeCompatibleWith(Long.class)));
Find a reproducing example in this commit. Steps to reproduce:
$ git clone https:$ cd hibernate-bugs/generic-id-types
$ mvn clean test
The build uses Hibernate 5.1 by default but the version can be tweaked by using the profiles declared in the parent POM. |