What kind of ID's are allowed in hibernate? int and long for sure! Can I use String or even something like a Map or a List?
Asked
Active
Viewed 5,028 times
1 Answers
4
You can create your own identifier, of any type.
Look at the reference documentation : http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/mapping.html#mapping-declaration-id

ndeverge
- 21,378
- 4
- 56
- 85
-
Well in the documentation it just says type="typename". Does that mean now i can just write type="LinkedList"????? How would that work then? – eclipse Jan 22 '12 at 13:09
-
-
Sorry that I have to ask again. So if I have a class with one attribute which is a LinkedList I still need a secound attribute called ID which I will generate using a generator? Could you be a bit more specific please I am new to the subject. – eclipse Jan 22 '12 at 13:30
-
Hibernate forces you to have an id for every entity. If you use annotations, look at http://stackoverflow.com/questions/2011528/hibernate-auto-increment-id, else look at http://stackoverflow.com/questions/1838520/hibernate-problems-with-auto-increment-id-mysql-5 – ndeverge Jan 22 '12 at 13:36