Search in sources :

Example 26 with MySQLDialect

use of org.hibernate.dialect.MySQLDialect 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();
}
Also used : HSQLDialect(org.hibernate.dialect.HSQLDialect) MckoiDialect(org.hibernate.dialect.MckoiDialect) MySQLDialect(org.hibernate.dialect.MySQLDialect) TimesTenDialect(org.hibernate.dialect.TimesTenDialect) PointbaseDialect(org.hibernate.dialect.PointbaseDialect) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 27 with MySQLDialect

use of org.hibernate.dialect.MySQLDialect in project hibernate-orm by hibernate.

the class LikeTest method testLike.

@Test
public void testLike() {
    Session session = openSession();
    Transaction tx = session.beginTransaction();
    TestObject obj = new TestObject();
    String uniq = "uniq" + System.currentTimeMillis();
    obj.setText("XyZ " + uniq + " blablabla");
    session.save(obj);
    session.flush();
    tx.commit();
    session.close();
    String pattern = "XyZ " + uniq + "%";
    // retrieve object - case sensitive - works ok
    session = openSession();
    tx = session.beginTransaction();
    List objects = session.createCriteria(TestObject.class).add(Restrictions.like("text", pattern)).list();
    assertEquals(1, objects.size());
    session.clear();
    // retrieve object - case insensitive - works ok
    objects = session.createCriteria(TestObject.class).add(Restrictions.like("text", pattern).ignoreCase()).list();
    assertEquals(1, objects.size());
    session.clear();
    if (!(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof PostgreSQLDialect) && !(getDialect() instanceof PostgreSQL81Dialect)) {
        // retrieve object - case insensitive via custom expression - works
        // ok
        objects = session.createCriteria(TestObject.class).add(StringExpression.stringExpression("text", pattern, true)).list();
        assertEquals(1, objects.size());
        session.clear();
        // retrieve object - case sensitive via custom expression - not
        // working
        objects = session.createCriteria(TestObject.class).add(StringExpression.stringExpression("text", pattern, false)).list();
        assertEquals(1, objects.size());
    }
    tx.rollback();
    session.close();
}
Also used : MySQLDialect(org.hibernate.dialect.MySQLDialect) PostgreSQLDialect(org.hibernate.dialect.PostgreSQLDialect) Transaction(org.hibernate.Transaction) List(java.util.List) Session(org.hibernate.Session) PostgreSQL81Dialect(org.hibernate.dialect.PostgreSQL81Dialect) Test(org.junit.Test)

Aggregations

MySQLDialect (org.hibernate.dialect.MySQLDialect)27 Session (org.hibernate.Session)26 Test (org.junit.Test)26 Transaction (org.hibernate.Transaction)18 HSQLDialect (org.hibernate.dialect.HSQLDialect)15 List (java.util.List)12 ArrayList (java.util.ArrayList)11 Iterator (java.util.Iterator)10 PointbaseDialect (org.hibernate.dialect.PointbaseDialect)7 SAPDBDialect (org.hibernate.dialect.SAPDBDialect)7 Serializable (java.io.Serializable)5 Query (org.hibernate.Query)5 DB2Dialect (org.hibernate.dialect.DB2Dialect)5 MckoiDialect (org.hibernate.dialect.MckoiDialect)5 Date (java.util.Date)4 AbstractHANADialect (org.hibernate.dialect.AbstractHANADialect)4 PostgreSQL81Dialect (org.hibernate.dialect.PostgreSQL81Dialect)4 TimesTenDialect (org.hibernate.dialect.TimesTenDialect)4 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3