Package org.hibernate.classic

Examples of org.hibernate.classic.Session.createSQLQuery()


      s = new Category();
      s.setName("WannaBeFound");
      session.flush();

      Query query = session.createSQLQuery("select {category.*} from category {category} where {category}.name = :name", "category", Category.class);

      query.setProperties(s);
      //query.setParameter("name", s.getName());

      query.list();
View Full Code Here


      query.setProperties(s);
      //query.setParameter("name", s.getName());

      query.list();

      query = session.createSQLQuery("select {category.*} from category {category} where {category}.name in (:names)", "category", Category.class);
      String[] str = new String[] { "WannaBeFound", "NotThere" };
      query.setParameterList("names", str);
     
      query.uniqueResult();
     
View Full Code Here

    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    List list = s.createSQLQuery("select {category.*} from category {category}", "category", Category.class).list();
    list.get(0);
    s.connection().commit();
    s.close();
   
    if ( getDialect() instanceof MySQLDialect ) return;
View Full Code Here

    s.close();

    if ( getDialect() instanceof MySQLDialect ) return;

    s = openSession();
    List list = s.createSQLQuery("select {category.*}, {assignable.*} from category {category}, \"assign-able\" {assignable}", new String[] { "category", "assignable" }, new Class[] { Category.class, Assignable.class }).list();

    assertTrue(list.size() == 6); // crossproduct of 2 categories x 3 assignables
    assertTrue(list.get(0) instanceof Object[]);
    s.connection().commit();
    s.close();
View Full Code Here

    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    Query basicParam = s.createSQLQuery("select {category.*} from category {category} where {category}.name = 'Best'", "category", Category.class);
    List list = basicParam.list();
    assertEquals(1, list.size());

    Query unnamedParam = s.createSQLQuery("select {category.*} from category {category} where {category}.name = ? or {category}.name = ?", "category", Category.class);
    unnamedParam.setString(0, "Good");
View Full Code Here

    s = openSession();
    Query basicParam = s.createSQLQuery("select {category.*} from category {category} where {category}.name = 'Best'", "category", Category.class);
    List list = basicParam.list();
    assertEquals(1, list.size());

    Query unnamedParam = s.createSQLQuery("select {category.*} from category {category} where {category}.name = ? or {category}.name = ?", "category", Category.class);
    unnamedParam.setString(0, "Good");
    unnamedParam.setString(1, "Best");
    list = unnamedParam.list();
    assertEquals(2, list.size());

View Full Code Here

    unnamedParam.setString(0, "Good");
    unnamedParam.setString(1, "Best");
    list = unnamedParam.list();
    assertEquals(2, list.size());

    Query namedParam = s.createSQLQuery("select {category.*} from category {category} where ({category}.name=:firstCat or {category}.name=:secondCat)", "category", Category.class);
    namedParam.setString("firstCat", "Better");
    namedParam.setString("secondCat", "Best");
    list = namedParam.list();
    assertEquals(2, list.size());

View Full Code Here

    session = openSession();

    Query query;
    if ( getDialect() instanceof OracleDialect ) {
      // Oracle8 does not support X/Open extension functions :)
      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 upper(name) like upper('max')", "a", A.class);
    }
    else 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'", "a", A.class);
View Full Code Here

      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 upper(name) like upper('max')", "a", A.class);
    }
    else 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'", "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')}", "a", A.class);
        }
    List list = query.list();
View Full Code Here

    else 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'", "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')}", "a", A.class);
        }
    List list = query.list();

    assertNotNull(list);
    assertEquals(1, list.size());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.