Value « Annotation « JPA Q&A





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

Say I have this class:

@Entity
@Table(name="PICTURE")
public class Picture{
   private String category1, category2;
}
but the database structure looks like this:
TABLE PICTURE {
   int category1;
   int category2;
   ...

2. generate value in annotations    forum.hibernate.org

@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    forum.hibernate.org

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