use of org.hibernate.dialect.PointbaseDialect in project hibernate-orm by hibernate.
the class FooBarTest method testAutoFlushCollections.
@Test
public void testAutoFlushCollections() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Baz baz = new Baz();
baz.setDefaults();
s.save(baz);
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
baz = (Baz) s.load(Baz.class, baz.getCode());
baz.getStringArray()[0] = "bark";
Iterator i = s.createQuery("select elements(baz.stringArray) from Baz baz").iterate();
boolean found = false;
while (i.hasNext()) {
if ("bark".equals(i.next()))
found = true;
}
assertTrue(found);
baz.setStringArray(null);
i = s.createQuery("select distinct elements(baz.stringArray) from Baz baz").iterate();
assertTrue(!i.hasNext());
baz.setStringArray(new String[] { "foo", "bar" });
i = s.createQuery("select elements(baz.stringArray) from Baz baz").iterate();
assertTrue(i.hasNext());
Foo foo = new Foo();
s.save(foo);
s.flush();
baz.setFooArray(new Foo[] { foo });
i = s.createQuery("select foo from Baz baz join baz.fooArray foo").iterate();
found = false;
while (i.hasNext()) {
if (foo == i.next())
found = true;
}
assertTrue(found);
baz.getFooArray()[0] = null;
i = s.createQuery("select foo from Baz baz join baz.fooArray foo").iterate();
assertTrue(!i.hasNext());
baz.getFooArray()[0] = foo;
i = s.createQuery("select elements(baz.fooArray) from Baz baz").iterate();
assertTrue(i.hasNext());
if (!(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof HSQLDialect) && !(getDialect() instanceof InterbaseDialect) && !(getDialect() instanceof PointbaseDialect) && !(getDialect() instanceof SAPDBDialect)) {
baz.getFooArray()[0] = null;
i = s.createQuery("from Baz baz where ? in elements(baz.fooArray)").setParameter(0, foo, s.getTypeHelper().entity(Foo.class)).iterate();
assertTrue(!i.hasNext());
baz.getFooArray()[0] = foo;
i = s.createQuery("select foo from Foo foo where foo in (select elt from Baz baz join baz.fooArray elt)").iterate();
assertTrue(i.hasNext());
}
s.delete(foo);
s.delete(baz);
tx.commit();
s.close();
}
use of org.hibernate.dialect.PointbaseDialect 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();
}
Aggregations