In Oracle we can create an update query that will return the updated record using the RETURNING clause.
Is there similar functionality in Hibernate?
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.
Apart from database-generated values there is obviously no need for Hibernate to return the updated instance because the object passed to
Session.saveOrUpdate()is the updated instance. Database-generated values (sequence, trigger, defaults, etc.) will be set afterSession.saveOrUpdateif they are accordingly annotated (or defined in a XML mapping file).For identifier values use the JPA
@javax.persistence.GeneratedValueannotation in conjunction with the JPA@javax.persistence.Idannotation. For simple properties use the native Hibernate@org.hibernate.annotations.Generatedannotation (afaik there is no according JPA annotation).How generated identifier values are retrieved by Hibernate depends on the generation strategy and/or the database dialect. For simple properties Hibernate executes an additional
SELECTby id statement after theINSERTorUPDATE.