Hi guys, this is my first post.
I have trouble getting Hibernate Automatic Versioning.
I use Annotation but seems that OptimisticLockType.ALL is ignored.
This is my entity class:
Code:
@Entity
@Table(name = "utente")
@org.hibernate.annotations.Entity(optimisticLock = OptimisticLockType.ALL, selectBeforeUpdate=true, dynamicUpdate = true)
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Utente.findAll", query = "SELECT u FROM Utente u"),
@NamedQuery(name = "Utente.findByUsername", query = "SELECT u FROM Utente u WHERE u.username = :username"),
@NamedQuery(name = "Utente.findByNome", query = "SELECT u FROM Utente u WHERE u.nome = :nome"),
@NamedQuery(name = "Utente.findByOnline", query = "SELECT u FROM Utente u WHERE u.online = :online"),
@NamedQuery(name = "Utente.findByEmail", query = "SELECT u FROM Utente u WHERE u.email = :email")})
public class Utente implements Serializable {
this is the code where i do the query:
Code:
@Override
public void merge(T istance)
{
sessionFactory.getCurrentSession().merge(istance);
}
If i create a version field and set @Version on that field, and also use OptimisticLockType.ALL the versioning work fine, like if I have set OptimisticLockType.VERSION.
Please help me I'm stuck.
Thank you in advance and sorry for my english.