use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class FooBarTest method testNewSessionLifecycle.
@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA currently requires specifying table name by 'FOR UPDATE of t1.c1' if there are more than one tables/views/subqueries in the FROM clause")
@Test
public void testNewSessionLifecycle() throws Exception {
Session s = openSession();
s.beginTransaction();
Serializable fid = null;
try {
Foo f = new Foo();
s.save(f);
fid = s.getIdentifier(f);
s.getTransaction().commit();
} catch (Exception e) {
s.getTransaction().rollback();
throw e;
} finally {
s.close();
}
s = openSession();
s.beginTransaction();
try {
Foo f = new Foo();
s.delete(f);
s.getTransaction().commit();
} catch (Exception e) {
s.getTransaction().rollback();
throw e;
} finally {
s.close();
}
s = openSession();
s.beginTransaction();
try {
Foo f = (Foo) s.load(Foo.class, fid, LockMode.UPGRADE);
s.delete(f);
s.flush();
s.getTransaction().commit();
} catch (Exception e) {
s.getTransaction().rollback();
throw e;
} finally {
s.close();
}
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class QueryByExampleTest method testJunctionNotExpressionQBE.
@Test
@SkipForDialect(value = SybaseASE15Dialect.class, jiraKey = "HHH-4580")
public void testJunctionNotExpressionQBE() throws Exception {
deleteData();
initData();
Session s = openSession();
Transaction t = s.beginTransaction();
Componentizable master = getMaster("hibernate", null, "ope%");
Criteria crit = s.createCriteria(Componentizable.class);
Example ex = Example.create(master).enableLike();
crit.add(Restrictions.or(Restrictions.not(ex), ex));
List result = crit.list();
assertNotNull(result);
assertEquals(2, result.size());
t.commit();
s.close();
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class SQLLoaderTest method testEscapedJDBC.
@Test
@SkipForDialect({ HSQLDialect.class, PostgreSQL81Dialect.class, PostgreSQLDialect.class })
public void testEscapedJDBC() throws HibernateException, SQLException {
Session session = openSession();
session.beginTransaction();
for (Object entity : session.createQuery("from A").list()) {
session.delete(entity);
}
A savedA = new A();
savedA.setName("Max");
session.save(savedA);
B savedB = new B();
session.save(savedB);
session.flush();
int count = session.createQuery("from A").list().size();
session.getTransaction().commit();
session.close();
session = openSession();
session.beginTransaction();
Query query;
if (getDialect() instanceof TimesTenDialect) {
// TimesTen does not permit general expressions (like UPPER) in the second part of a LIKE expression,
// so we execute a similar test
query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like 'MAX'").addEntity("a", A.class);
} else {
query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like {fn ucase('max')}").addEntity("a", A.class);
}
List list = query.list();
assertNotNull(list);
assertEquals(1, list.size());
session.getTransaction().commit();
session.close();
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class SQLLoaderTest method testFindSimpleBySQL.
@Test
@SkipForDialect(MySQLDialect.class)
public void testFindSimpleBySQL() throws Exception {
Session session = openSession();
session.beginTransaction();
Category s = new Category();
s.setName(String.valueOf(nextLong++));
session.save(s);
session.flush();
Query query = session.createSQLQuery("select s.category_key_col as {category.id}, s.name as {category.name}, s.\"assign-able-id\" as {category.assignable} from {category} s").addEntity("category", Category.class);
List list = query.list();
assertNotNull(list);
assertTrue(list.size() > 0);
assertTrue(list.get(0) instanceof Category);
session.getTransaction().commit();
session.close();
// How do we handle objects with composite id's ? (such as Single)
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class BlobLocatorTest method testBoundedBlobLocatorAccess.
@Test
@SkipForDialect(value = TeradataDialect.class, jiraKey = "HHH-6637", comment = "Teradata requires locator to be used in same session where it was created/retrieved")
public void testBoundedBlobLocatorAccess() throws Throwable {
byte[] original = buildByteArray(BLOB_SIZE, true);
byte[] changed = buildByteArray(BLOB_SIZE, false);
byte[] empty = new byte[] {};
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setBlobLocator(s.getLobHelper().createBlob(original));
s.save(entity);
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = s.get(LobHolder.class, entity.getId());
Assert.assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
assertEquals(original, extractData(entity.getBlobLocator()));
s.getTransaction().commit();
s.close();
// test mutation via setting the new clob data...
if (getDialect().supportsLobValueChangePropogation()) {
s = openSession();
s.beginTransaction();
entity = (LobHolder) s.byId(LobHolder.class).with(LockOptions.UPGRADE).load(entity.getId());
entity.getBlobLocator().truncate(1);
entity.getBlobLocator().setBytes(1, changed);
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = (LobHolder) s.byId(LobHolder.class).with(LockOptions.UPGRADE).load(entity.getId());
assertNotNull(entity.getBlobLocator());
Assert.assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
assertEquals(changed, extractData(entity.getBlobLocator()));
entity.getBlobLocator().truncate(1);
entity.getBlobLocator().setBytes(1, original);
s.getTransaction().commit();
s.close();
}
// test mutation via supplying a new clob locator instance...
s = openSession();
s.beginTransaction();
entity = (LobHolder) s.byId(LobHolder.class).with(LockOptions.UPGRADE).load(entity.getId());
assertNotNull(entity.getBlobLocator());
Assert.assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
assertEquals(original, extractData(entity.getBlobLocator()));
entity.setBlobLocator(s.getLobHelper().createBlob(changed));
s.getTransaction().commit();
s.close();
// test empty blob
s = openSession();
s.beginTransaction();
entity = s.get(LobHolder.class, entity.getId());
Assert.assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
assertEquals(changed, extractData(entity.getBlobLocator()));
entity.setBlobLocator(s.getLobHelper().createBlob(empty));
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = s.get(LobHolder.class, entity.getId());
if (entity.getBlobLocator() != null) {
Assert.assertEquals(empty.length, entity.getBlobLocator().length());
assertEquals(empty, extractData(entity.getBlobLocator()));
}
s.delete(entity);
s.getTransaction().commit();
s.close();
}
Aggregations