Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Problems with mapping having @Id with @GeneratedValue in @MappedSuperClass but the sequence in subclass

Hi.
 
In Hibernate this inheritance-schema works (this is Scala-code but you get it):
@MappedSuperclass
abstract class AbstractDomainObject {
        @Id
        @Column(name = "id")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
        var id: java.lang.Long = null
}
@Entity
@Table(name = "project")
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "project_id_seq", allocationSize = 1)
class Project extends AbstractDomainObject
 
But in EL I get this exception:
Exception Description: Conflicting annotations with the same name [SEQ_STORE] were found. The first one [@javax.persistence.SequenceGenerator({sequenceName=rpm_user_id_seq, name=SEQ_STORE, allocationSize=1})] was found within [class no.officenet.example.rpm.support.domain.model.entities.User] and the second [@javax.persistence.SequenceGenerator({sequenceName=project_id_seq, name=SEQ_STORE, allocationSize=1})] was found within [class no.officenet.example.rpm.projectmgmt.domain.model.entities.Project]. Named annotations must be unique across the persistence unit.
 
 
The thing is that I have lots of entities inheriting from my AbstractDomainObject, which defines the @Id, but the sequence to use is defined in the child-entities because it's table-specific. I'd rather not define the @Id in all my child-entities.
 
Is there a way to accomplish this in EL?
 
Thanks.
 
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc

Back to the top