use of org.hibernate.testing.SkipForDialect 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.testing.SkipForDialect in project hibernate-orm by hibernate.
the class QueryTest method testNullPositionalParameterParameter.
@Test
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
public void testNullPositionalParameterParameter() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
try {
Item item = new Item("Mouse", "Micro$oft mouse");
em.persist(item);
Query q = em.createQuery("from Item i where i.intVal=?");
Parameter p = new Parameter() {
@Override
public String getName() {
return null;
}
@Override
public Integer getPosition() {
return 0;
}
@Override
public Class getParameterType() {
return Integer.class;
}
};
q.setParameter(p, null);
Parameter pGotten = q.getParameter(p.getPosition());
List results = q.getResultList();
// null != null
assertEquals(0, results.size());
q = em.createQuery("from Item i where i.intVal is null and ? is null");
q.setParameter(p, null);
results = q.getResultList();
assertEquals(1, results.size());
q = em.createQuery("from Item i where i.intVal is null or i.intVal = ?");
q.setParameter(p, null);
results = q.getResultList();
assertEquals(1, results.size());
} finally {
if (em.getTransaction() != null && em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class QueryTest method testNativeQueryNullNamedParameter.
@Test
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
public void testNativeQueryNullNamedParameter() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
try {
Item item = new Item("Mouse", "Micro$oft mouse");
em.persist(item);
// native queries don't seem to flush by default ?!?
em.flush();
Query q = em.createNativeQuery("select * from Item i where i.intVal=:iVal");
q.setParameter("iVal", null);
List results = q.getResultList();
// null != null
assertEquals(0, results.size());
q = em.createNativeQuery("select * from Item i where (i.intVal is null) and (:iVal is null)");
q.setParameter("iVal", null);
results = q.getResultList();
assertEquals(1, results.size());
q = em.createNativeQuery("select * from Item i where i.intVal is null or i.intVal = :iVal");
q.setParameter("iVal", null);
results = q.getResultList();
assertEquals(1, results.size());
} finally {
if (em.getTransaction() != null && em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class QueryTest method testNullPositionalParameterParameterIncompatible.
@Test
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
public void testNullPositionalParameterParameterIncompatible() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
try {
Item item = new Item("Mouse", "Micro$oft mouse");
em.persist(item);
Query q = em.createQuery("from Item i where i.intVal=?");
Parameter p = new Parameter() {
@Override
public String getName() {
return null;
}
@Override
public Integer getPosition() {
return 0;
}
@Override
public Class getParameterType() {
return Long.class;
}
};
q.setParameter(p, null);
Parameter pGotten = q.getParameter(p.getPosition());
List results = q.getResultList();
// null != null
assertEquals(0, results.size());
q = em.createQuery("from Item i where i.intVal is null and ? is null");
q.setParameter(p, null);
results = q.getResultList();
assertEquals(1, results.size());
q = em.createQuery("from Item i where i.intVal is null or i.intVal = ?");
q.setParameter(p, null);
results = q.getResultList();
assertEquals(1, results.size());
} finally {
if (em.getTransaction() != null && em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.
the class QueryTest method testNullPositionalParameter.
@Test
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
public void testNullPositionalParameter() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
try {
Item item = new Item("Mouse", "Micro$oft mouse");
em.persist(item);
Query q = em.createQuery("from Item i where i.intVal=?");
q.setParameter(0, null);
List results = q.getResultList();
// null != null
assertEquals(0, results.size());
q = em.createQuery("from Item i where i.intVal is null and ? is null");
q.setParameter(0, null);
results = q.getResultList();
assertEquals(1, results.size());
q = em.createQuery("from Item i where i.intVal is null or i.intVal = ?");
q.setParameter(0, null);
results = q.getResultList();
assertEquals(1, results.size());
} finally {
if (em.getTransaction() != null && em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
Aggregations