Example usage for org.hibernate.usertype UserType replace

List of usage examples for org.hibernate.usertype UserType replace

Introduction

In this page you can find the example usage for org.hibernate.usertype UserType replace.

Prototype

Object replace(Object original, Object target, Object owner) throws HibernateException;

Source Link

Document

During merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging.

Usage

From source file:org.codekaizen.vtj.hibernate3.AbstractValueTypeUserTypeTest.java

License:Open Source License

@Test
public void givenVTObjectWhenReplaceThenReturnSameObject() {
    UserType ut = this.newUserTypeInstance();
    ValueType<?> vt1 = this.getDefaultTestInstance();
    TestEntity entity = this.newTestEntity();
    TestEntity entity2 = this.newTestEntity();
    ValueType<?> vt2 = (ValueType<?>) ut.replace(vt1, entity, entity2);
    assertEquals(vt2, vt1);//from ww w  .j  av a 2 s .c om
    assertTrue(vt1 == vt2);
}

From source file:org.codekaizen.vtj.hibernate3.AbstractValueTypeUserTypeTest.java

License:Open Source License

@Test
public void givenNullWhenReplaceThenReturnNull() {
    UserType ut = this.newUserTypeInstance();
    TestEntity entity = this.newTestEntity();
    TestEntity entity2 = this.newTestEntity();
    assertNull(ut.replace(null, entity, entity2));
}