Search in sources :

Example 1 with UuidTestEntity

use of org.apache.cayenne.testdo.uuid.UuidTestEntity in project cayenne by apache.

the class UUIDIT method testUUID.

@Test
public void testUUID() throws Exception {
    UuidTestEntity test = context.newObject(UuidTestEntity.class);
    UUID id = UUID.randomUUID();
    test.setUuid(id);
    context.commitChanges();
    SelectQuery<UuidTestEntity> q = new SelectQuery<>(UuidTestEntity.class);
    UuidTestEntity testRead = (UuidTestEntity) context.performQuery(q).get(0);
    assertNotNull(testRead.getUuid());
    assertEquals(id, testRead.getUuid());
    test.setUuid(null);
    context.commitChanges();
}
Also used : SelectQuery(org.apache.cayenne.query.SelectQuery) UUID(java.util.UUID) UuidTestEntity(org.apache.cayenne.testdo.uuid.UuidTestEntity) Test(org.junit.Test)

Example 2 with UuidTestEntity

use of org.apache.cayenne.testdo.uuid.UuidTestEntity in project cayenne by apache.

the class UUIDIT method testUUIDColumnSelect.

@Test
public void testUUIDColumnSelect() throws Exception {
    UuidTestEntity test = context.newObject(UuidTestEntity.class);
    UUID id = UUID.randomUUID();
    test.setUuid(id);
    context.commitChanges();
    UUID readValue = ObjectSelect.query(UuidTestEntity.class).column(UuidTestEntity.UUID).selectOne(context);
    assertEquals(id, readValue);
    UUID readValue2 = ObjectSelect.query(UuidTestEntity.class).column(Property.create(ExpressionFactory.dbPathExp("UUID"), UUID.class)).selectOne(context);
    assertEquals(id, readValue2);
}
Also used : UUID(java.util.UUID) UuidTestEntity(org.apache.cayenne.testdo.uuid.UuidTestEntity) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)2 UuidTestEntity (org.apache.cayenne.testdo.uuid.UuidTestEntity)2 Test (org.junit.Test)2 SelectQuery (org.apache.cayenne.query.SelectQuery)1