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. 15:30:27, skrev Guy Pelletier <guy.pelletier@xxxxxxxxxx>:
I can't think of a good workaround other than what you have already mentioned, that is, defining the id on each subclass.

Another solution and perhaps a good suggestion for the JPA expert group would be to allow this through an @AttributeOverride, e.g.

@AttributeOverride(
  name="id",
  generatedValue=@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE_PROJECT")
)

@SequenceGenerator(name = "SEQ_STORE_PROJECT", sequenceName = "project_id_seq", allocationSize = 1)
class Project extends AbstractDomainObject

@AttributeOverride(
  name="id",
  generatedValue=
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE_USER")
)

@SequenceGenerator(name = "SEQ_STORE_USER", sequenceName = "user_id_seq", allocationSize = 1)
class User extends AbstractDomainObject

This maitains the unique naming across the persistence unit and leverages the existing attribute override functionality.

Please enter a bug against EclipseLink though. Similarly to Hibernate which provided a feature above and beyond the spec, EclipseLink could do the same.
 
Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=412408
 
--
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