I am using Java and Hibernate as ORM tool. Is there any way i can implement sequence in Java using Hibernate?
Currently I am using Oracle sequences to achieve this, but that is a very costly way as interaction with database increases.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is actually a very easy thing to do:
IdentitfierGeneratoris the hibernate interface you have to implement. The above example just generates a random id.In order to use this you have to set the
generatortomypackage.RandomIdentifierGeneratorObviously this implementation lacks any guarantee of not generating the same id twice, this may or may not be important for the application you are writing.