Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Common superclass to all entities in EJB3.0

Pieter-Jan Malfait
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic