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...