2

I want to use hibernate against an existing database. I need to mostly read data from the db and very occasionally modify a field.

I want to be able to update a single field in the row, but i need to make sure that all the other fields are not touched.

Does hibernate guarantee that a field will be written back the same as it was written (assuming i haven't modified the object)

2 Answers 2

2

Make the other fields insertable=false, updateable=false should work. It should tell Hibernate that update on those field won't be reflected in DB

Sign up to request clarification or add additional context in comments.

1 Comment

i ended up using this. Thanks.
2

I want to be able to update a single field in the row, but i need to make sure that all the other fields are not touched.

That's possible if you use "dynamic updates". Here is what the documentation writes about this setting:

dynamic-update (optional - defaults to false): specifies that UPDATE SQL should be generated at runtime and can contain only those columns whose values have changed.

If you don't use this, all writable (see insert, update) properties will be part of the update.

But if you didn't change anything values, Hibernate won't change them on your back.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.