use of org.hibernate.dialect.HSQLDialect in project hibernate-orm by hibernate.
the class MasterDetailTest method testSelfManyToOne.
@Test
public void testSelfManyToOne() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Master m = new Master();
m.setOtherMaster(m);
s.save(m);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
Iterator i = s.createQuery("from Master").iterate();
m = (Master) i.next();
assertTrue(m.getOtherMaster() == m);
if (getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect) {
m.setOtherMaster(null);
s.flush();
}
s.delete(m);
t.commit();
s.close();
}
use of org.hibernate.dialect.HSQLDialect in project hibernate-orm by hibernate.
the class FumTest method testCompositeKeyPathExpressions.
@Test
@SkipForDialect(value = SybaseASE15Dialect.class, jiraKey = "HHH-3690")
public void testCompositeKeyPathExpressions() throws Exception {
Session s = openSession();
s.beginTransaction();
s.createQuery("select fum1.fo from Fum fum1 where fum1.fo.fum is not null").list();
s.createQuery("from Fum fum1 where fum1.fo.fum is not null order by fum1.fo.fum").list();
if (!(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof HSQLDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof PointbaseDialect)) {
s.createQuery("from Fum fum1 where exists elements(fum1.friends)").list();
if (!(getDialect() instanceof TimesTenDialect)) {
// can't execute because TimesTen can't do subqueries combined with aggreations
s.createQuery("from Fum fum1 where size(fum1.friends) = 0").list();
}
}
s.createQuery("select elements(fum1.friends) from Fum fum1").list();
s.createQuery("from Fum fum1, fr in elements( fum1.friends )").list();
s.getTransaction().commit();
s.close();
}
use of org.hibernate.dialect.HSQLDialect in project hibernate-orm by hibernate.
the class IJTest method testFormulaDiscriminator.
@Test
public void testFormulaDiscriminator() throws Exception {
if (getDialect() instanceof HSQLDialect)
return;
Session s = sessionFactory().openSession();
s.beginTransaction();
I i = new I();
i.setName("i");
i.setType('a');
J j = new J();
j.setName("j");
j.setType('x');
j.setAmount(1.0f);
Serializable iid = s.save(i);
Serializable jid = s.save(j);
s.getTransaction().commit();
s.close();
sessionFactory().getCache().evictEntityRegion(I.class);
s = sessionFactory().openSession();
s.beginTransaction();
j = (J) s.get(I.class, jid);
i = (I) s.get(I.class, iid);
assertTrue(i.getClass() == I.class);
j.setAmount(0.5f);
s.lock(i, LockMode.UPGRADE);
s.getTransaction().commit();
s.close();
s = sessionFactory().openSession();
s.beginTransaction();
j = (J) s.byId(I.class).with(LockOptions.UPGRADE).load(jid);
i = (I) s.byId(I.class).with(LockOptions.UPGRADE).load(iid);
s.getTransaction().commit();
s.close();
s = sessionFactory().openSession();
s.beginTransaction();
assertTrue(s.createQuery("from I").list().size() == 2);
assertTrue(s.createQuery("from J").list().size() == 1);
assertTrue(s.createQuery("from I i where i.class = 0").list().size() == 1);
assertTrue(s.createQuery("from I i where i.class = 1").list().size() == 1);
s.getTransaction().commit();
s.close();
s = sessionFactory().openSession();
s.beginTransaction();
j = (J) s.get(J.class, jid);
i = (I) s.get(I.class, iid);
s.delete(j);
s.delete(i);
s.getTransaction().commit();
s.close();
}
use of org.hibernate.dialect.HSQLDialect in project hibernate-orm by hibernate.
the class CompositeUserTypeTest method testCompositeUserType.
@Test
public void testCompositeUserType() {
Session s = openSession();
org.hibernate.Transaction t = s.beginTransaction();
Transaction tran = new Transaction();
tran.setDescription("a small transaction");
tran.setValue(new MonetoryAmount(new BigDecimal(1.5), Currency.getInstance("USD")));
s.persist(tran);
List result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'USD'").list();
assertEquals(result.size(), 1);
tran.getValue().setCurrency(Currency.getInstance("AUD"));
result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'AUD'").list();
assertEquals(result.size(), 1);
if (!(getDialect() instanceof HSQLDialect)) {
result = s.createQuery("from Transaction txn where txn.value = (1.5, 'AUD')").list();
assertEquals(result.size(), 1);
result = s.createQuery("from Transaction where value = (1.5, 'AUD')").list();
assertEquals(result.size(), 1);
result = s.createQuery("from Transaction where value != (1.4, 'AUD')").list();
assertEquals(result.size(), 1);
}
s.delete(tran);
t.commit();
s.close();
}
Aggregations