Example usage for org.hibernate.type Type isModified

List of usage examples for org.hibernate.type Type isModified

Introduction

In this page you can find the example usage for org.hibernate.type Type isModified.

Prototype

boolean isModified(Object dbState, Object currentState, boolean[] checkable,
        SharedSessionContractImplementor session) throws HibernateException;

Source Link

Document

Has the value been modified compared to the current database state?

Usage

From source file:org.riotfamily.common.hibernate.AnyIdAnyType.java

License:Apache License

public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session)
        throws HibernateException {
    if (current == null)
        return old != null;
    if (old == null)
        return current != null;
    ObjectTypeCacheEntry holder = (ObjectTypeCacheEntry) old;
    boolean[] idcheckable = new boolean[checkable.length - 1];
    System.arraycopy(checkable, 1, idcheckable, 0, idcheckable.length);

    if (checkable[0] && !holder.entityName.equals(session.bestGuessEntityName(current))) {
        return true;
    }/*from   w  ww  .  j  ava  2s .  c  o  m*/
    Type idType = getIdType(holder.entityName, session);
    return idType.isModified(holder.id, getIdentifier(current, session), idcheckable, session);
}