Skip to main content

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

På fredag 05. juli 2013 kl. 14:30:47, skrev Tom Ware <tom.ware@xxxxxxxxxx>:
The exception refers to no.officenet.example.rpm.support.domain.model.entities.User.  Is there a SequenceGenerator defined there?
 
Yes, that's the point; All my Entities inherit from AbstractDomainObject and define their own SequenceGenerator. I'd like to be able to have all my Entities inherit from a @MappedSuperclass (which defines the @Id column with a @GeneratedValue) and where each child provide provide their own sequence-name, by using the SequenceGenerator annotation. This schema works in Hibernate but seems to be against the standard, which states that the SequenceGenerator's name must be unique across the PU.
 
Is there a workaround I can use which lets me use @GeneratedValue in the @MappedSuperclass and where each child provide their own sequence-name?
LIke this:
@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
@Entity
@Table(name = "user")
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "user_id_seq", allocationSize = 1)
class User extends AbstractDomainObject

Having to define @Id in each sub-class just to acomplish this seems unnecessary and is what I'm hoping to avoid.
 
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