Open ZZerog opened 3 years ago
OK. This is a working java solution. But a better solution (I think) is to generate UUID on the SQL side.
@Column(name = "verification_hash")
public UUID verificationHash = UUID.randomUUID();
I actually use the Java solution in my apps because it solves a problem with batch inserts. The postgres jdbc driver does not return generated ids in the correct order when you do a batch insert.
For single inserts add the @Id and @GeneratedValue annotations to your primary key. See the docs.
Reopen this issue if that doesn't solve the problem.
When the column is a primary key, annotations work as expected, but what to do when the column is NOT the primary key? @GeneratedValue works only with Long value and means something as 'auto increment', right ?
So the java solution is only working solutions
Are you using the most recent version of Norm? 1.0.4. There were a few changes to the way generated values are returned.
Try it with just @GeneratedValue. If that doesn't work, I'll have a look at it.
Hi. I still cannot catch this situation.
table column:
verification_hash uuid DEFAULT uuid_generate_v1() UNIQUE
POJO:
When the insert method is called, column verification_hash is null. I will try to implement my own JPA serialization for that or am I doing something wrong? Missing some annotation or something?
Thx