org.hibernate.AnnotationException: No identifier specified for entity

entity-framework groovy hibernate java orm

Accepted Answer

Your inheritance mapping difficulty scenario. Your super class has an Id field, but what about your kid class? How will they be related to their parents?

An inheritance hierarchy can be mapped using a variety of methods.

  1. Discriminator value usage (Single Table)
  2. Table for each specific class
  3. Tables per class of children (if parent is an abstract)

I believe you are lacking the above-related annotations.

In a discriminator-based method, your ParentClass must be annotated as follows:

@Inheritance(strategy=InheritanceType.SINGLE_TABLE)  
@DiscriminatorColumn(name="type",discriminatorType=DiscriminatorType.STRING)  
@DiscriminatorValue(value="ParentClass")  

In your child's class, too:

@DiscriminatorValue("childClasss")

Please consult a tutorial on inheritance mapping, such as like as, or search for it online.

6
3/4/2014 4:18:51 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow