In my project which is based on Hibernate
and MySQL
I'm using barcode so I have set primary key
to bracode
as well as id
field and since there's composition it's problematic that occurring :
org.hibernate.id.IdentifierGenerationException: null id generated for:class com.pojo.MyClass
So I'm not using @annotations
I've checked without composition and just make barcode unique rather set primary key
so would this approach could be cause of any future problem in my project?
If the barcode for you entity is unique identifier just put @Id annotation on this field and put the unique constrain in the data base for that field as well. If you are using several fields as unique constrain in this case you should use composite key. If I get you question right.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.