Ryan
Ryan

Reputation: 3619

Hibernate updating a single column

I am confused as to the stance Hibernate takes when it determines which column information to persist. Some places I read online says it will only update dirty fields, some people say that it is also database dependant (ie. Using hibernate with Oracle 9 will persist all fields of an object, even if only 1 is dirty).

Is there a correct way to handle this if you only want column xxx to change? Or should that simply be abstracted to a different table? Lastly, is any of this affected whether you use Session#get or Session#load?

Upvotes: 2

Views: 5211

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340733

Use dynammic-update Hibernate mapping attribute:

<class ... dynamic-update="true">

Source: Hibernate – dynamic-update attribute example.

Upvotes: 3

Related Questions