14

I'm trying to duplicate something you can do in .Net but not having much luck.

Is the following not possible in Java or am I just missing something? When I run it I get told there is no identifier specified for entity Group.

public abstract class RCEntity
{
   @Id @GeneratedValue
   private int id;

   //getters & setters
}

@Entity 
public class Group extends RCEntity {
}
Daniel Daranas
  • 22,454
  • 9
  • 63
  • 116
Shane Courtrille
  • 13,960
  • 22
  • 76
  • 113
  • On a side note, these annotations are part of the JPA standard, and not necessarily Hibernate specific. – Powerlord Nov 03 '10 at 16:51

2 Answers2

22

Add the annotation @MappedSuperclass to your super class, i.e.

@MappedSuperclass
public abstract class RCEntity
{
   @Id @GeneratedValue
   private int id;

   //getters & setters
}
William
  • 13,332
  • 13
  • 60
  • 73
4

From this section in the docs:

Any class in the hierarchy non annotated with @MappedSuperclass nor @Entity will be ignored.

oksayt
  • 4,333
  • 1
  • 22
  • 41