Value « Annotation « JPA Q&A

1. JPA annotation to add and view values from a reference table

Say I have this class:

public class Picture{
   private String category1, category2;
but the database structure looks like this:
   int category1;
   int category2;

2. generate value in annotations

@Id @GeneratedValue @Column(name = "MESSAGE_ID") private Long id; If i try to use above statement. The hibernate_sequence sequence is being used, but i have not specified the sequence in my GeneratedValue. It means that hibernate_sequence is being used by default for Id generation. In case 2 threads simultaneously try to save an object, how will the sequence number generation take place ...

3. Annotation defaul value or unsaved value

I have the same problem and I search on forums and I reached the conclusion that there is no annotation support for specifying a column's default value. This is very strange since in the xml mapping you can put default value for a column. I am not sure if I am right but maybe someone from the hibernate team can help ...