How do I persist objects of a class in hibernate without them having an id attribute but using their object identity.
Share
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.
You can’t. You have to designate a field that will hold the
@Idfor the entity.The object identity can’t be translated to a database primary key, and a primary key is a requirement.
There’s another thing here – the
equalsandhashcodemethods are usually incorrectly implemented using the@Idfield. You can use the default implementations which rely on object identity.