If you are using openSession() then you have to use both DynamicUpdate and SelectBeforeUpdate to make it effective.
As openSession every time opens new session, any object you want to update, that object doesn't lies in that session so you have to use SelectBeforeUpdate to retrieve that object in session. Then and then hibernate can determine how many fields are actually changed. So hibernate will update only changed field as we have set DynamicUpdate=true.
If you are using annotation then syntax should be like
@Entity
@Table(name = "Abc", catalog = "xyz")
@org.hibernate.annotations.Entity(dynamicUpdate = true, selectBeforeUpdate = true)
public class Abc implements java.io.Serializable {
...
...
}
If you are using latest jar files then dynamicUpdate and selectBeforeUpdate are deprecated.
For that syntax should be like
@Entity
@Table(name = "Abc", catalog = "xyz")
@DynamicUpdate
@SelectBeforeUpdate
public class Abc implements java.io.Serializable {
...
...
}
And if you are using getCurrentSession() then no need to use SelectBeforeUpdate as object is already lies in session.
I recommend that use openSession() method instead getCurrentSession() because getCurrentSession automatically flush the session as well as close the session. It may chance to face problem in getCurrentSession method. While in openSession we have to manage all the things.
As openSession every time opens new session, any object you want to update, that object doesn't lies in that session so you have to use SelectBeforeUpdate to retrieve that object in session. Then and then hibernate can determine how many fields are actually changed. So hibernate will update only changed field as we have set DynamicUpdate=true.
If you are using annotation then syntax should be like
@Entity
@Table(name = "Abc", catalog = "xyz")
@org.hibernate.annotations.Entity(dynamicUpdate = true, selectBeforeUpdate = true)
public class Abc implements java.io.Serializable {
...
...
}
If you are using latest jar files then dynamicUpdate and selectBeforeUpdate are deprecated.
For that syntax should be like
@Entity
@Table(name = "Abc", catalog = "xyz")
@DynamicUpdate
@SelectBeforeUpdate
public class Abc implements java.io.Serializable {
...
...
}
And if you are using getCurrentSession() then no need to use SelectBeforeUpdate as object is already lies in session.
I recommend that use openSession() method instead getCurrentSession() because getCurrentSession automatically flush the session as well as close the session. It may chance to face problem in getCurrentSession method. While in openSession we have to manage all the things.