Skip to main content

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

Please also log a bug for the ignored SequenceGenerator.  As a workaround you
can put it on an Entity class, or on the id.


Christopher Schmidt-5 wrote:
> 
> Hi James,
> since I am using it like that:
> public class User {  @EmbeddedId  public UserId user = new UserId();}
> 
> It works fine, thanks.
> 
> And BTW the SequenceGenerator annotation is ignored... A new sequence
> is generated, but with name "XXX" not "XXXseq"?
> 
> Christopher
> 
> On Wed, Mar 2, 2011 at 4:51 PM, James Sutherland <jamesssss@xxxxxxxxx>
> wrote:
> 
> What object are you persisting?  Does it have a UserId or is it null?  You
> must initialize it to have a UserId, it can't be null.
> 
> Also log a bug, a null pointer should not be occurring.
> 
> 
> Christopher Schmidt-5 wrote:
>>
>> 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
>> blog: http://blog.fakod.eu
>>
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Embeddable-Id-class-and-GeneratedValue-annotation-tp31031870p31108146.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top