5 Replies Latest reply on Oct 5, 2005 11:29 AM by Patrik Björling Rygert

    Common superclass to all entities?

    Pieter-Jan Malfait Newbie

      i want all my entities to contains fields that hold when they are last modified and by wath user. i created a superclass called BaseEntity that implements these properties and als holds the id because all other entities in the project will inherit from this base class.

      i use TABLE_PER_CLASS as inheritence strategy. i'm having trouble with the id assignment for my entities.. when i use GeneratorType.AUTO (as i did before) i get this error message :

      Problem creating service jboss.j2ee:service=EJB3,module=support.par
      org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for:

      When i try GeneratorType.TABLE or GeneratorType.SEQUENCE, none of my entities get an id (they all have 0).

      I also tried to implement this superclass as and EmbeddableSuperClass but as i need to hold a reference to a user (which is also an entity) i can't use an EmbeddableSuperclass because it can only hold basic types as attributes.

      Anyone knows what the prolem could be? Or is there any other, better strategy to get these attributes into each entity in de system?

      Thx a lot in advance