Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Embeddable Id class and GeneratedValue annotation

Hi, where do I have to place the @GeneratedValue Annotation when I use a EmbeddedId class. 

Like this?

@Embeddable
@SequenceGenerator(name = "XXX", sequenceName = "XXXseq")
class UserId implements Serializable {

   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "XXX")
   BigInteger id;
}

Does not work, thats why I'm asking ;-) I'm getting a NPE (think field id is null):

org.specs.runner.UserError: java.lang.NullPointerException: null
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:92)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:61)
at org.eclipse.persistence.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:523)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.getBaseValueForField(ObjectBuilder.java:2484)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:284)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:454)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:4190)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:493)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4135)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:406)
at org.jpaextension.manager.EntityManagerWrapper$class.persistAndFlush(EntityManagerWrapper.scala:114)
at org.jpaextension.test.OrgStructEmbeddedIdTest.persistAndFlush(OrgStructEmbeddedIdTest.scala:9)

What is wrong?

using EclipseLink 2.2.0

--
Christopher
twitter: @fakod


Back to the top