-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem (NullPointerException) setting id properties
PostPosted: Thu May 12, 2011 2:49 am 
Beginner
Beginner

Joined: Tue Dec 21, 2010 5:26 am
Posts: 25
Hi all,

I have a table configured with a sequence generator on the database side and a corresponding mapping on the java side.

Code:
@SequenceGenerator(name = "generator", sequenceName = "myschema.customer_id_seq")
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "generator")
@Column(name = "customer_id", unique = true, nullable = false)
public Long getCustomerId()
{
   return this.customerId;
}


Now if I set all the properties I want (except the customerId one) everything works o.k. But if also set the customerId property (to bypass the generator) I get a NullPointerException upon commit. In the EntityEntry.class:
Code:
return loadedState[propertyIndex]

loadedState is an Object[] which sure is null at the time. But that really doesn't help me figuring out why it's null.

Now I've already look at similar topics on stackoverflow.com and it seems there are a few workarounds. But those people describe a different exception. Some along the lines of "...detached instance ... something something..."


Anyway, my question is simply: Can I somehow bypass the generated id and set my own instead? I need this for recreating "old" records...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.