Search in sources :

Example 86 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class NativeSQLQueriesTest method testTextTypeInSQLQuery.

@SkipForDialect(value = AbstractHANADialect.class, comment = "On HANA, this returns an clob for the text column which doesn't get mapped to a String")
@Test
public void testTextTypeInSQLQuery() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    String description = buildLongString(15000, 'a');
    TextHolder holder = new TextHolder(description);
    s.persist(holder);
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    String descriptionRead = (String) s.createSQLQuery(getDescriptionsSQL()).uniqueResult();
    assertEquals(description, descriptionRead);
    s.delete(holder);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) TextHolder(org.hibernate.test.sql.hand.TextHolder) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 87 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class UnionSubclassFilterTest method testFiltersWithUnionSubclass.

@Test
@SkipForDialect(value = TeradataDialect.class, jiraKey = "HHH-8190", comment = "uses Teradata reserved word - title")
@SuppressWarnings({ "unchecked" })
public void testFiltersWithUnionSubclass() {
    Session s = openSession();
    s.enableFilter("region").setParameter("userRegion", "US");
    Transaction t = s.beginTransaction();
    prepareTestData(s);
    s.clear();
    List results;
    Iterator itr;
    results = s.createQuery("from Person").list();
    assertEquals("Incorrect qry result count", 4, results.size());
    s.clear();
    results = s.createQuery("from Employee").list();
    assertEquals("Incorrect qry result count", 2, results.size());
    s.clear();
    results = new ArrayList(new HashSet(s.createQuery("from Person as p left join fetch p.minions").list()));
    assertEquals("Incorrect qry result count", 4, results.size());
    itr = results.iterator();
    while (itr.hasNext()) {
        // find john
        final Person p = (Person) itr.next();
        if (p.getName().equals("John Doe")) {
            Employee john = (Employee) p;
            assertEquals("Incorrect fecthed minions count", 1, john.getMinions().size());
            break;
        }
    }
    s.clear();
    results = new ArrayList(new HashSet(s.createQuery("from Employee as p left join fetch p.minions").list()));
    assertEquals("Incorrect qry result count", 2, results.size());
    itr = results.iterator();
    while (itr.hasNext()) {
        // find john
        final Person p = (Person) itr.next();
        if (p.getName().equals("John Doe")) {
            Employee john = (Employee) p;
            assertEquals("Incorrect fecthed minions count", 1, john.getMinions().size());
            break;
        }
    }
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    for (Object entity : s.createQuery("from Person").list()) {
        s.delete(entity);
    }
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Session(org.hibernate.Session) HashSet(java.util.HashSet) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Aggregations

SkipForDialect (org.hibernate.testing.SkipForDialect)87 Test (org.junit.Test)86 Session (org.hibernate.Session)66 Transaction (org.hibernate.Transaction)36 List (java.util.List)26 ArrayList (java.util.ArrayList)20 TestForIssue (org.hibernate.testing.TestForIssue)16 EntityManager (javax.persistence.EntityManager)15 Query (javax.persistence.Query)11 Item (org.hibernate.jpa.test.Item)10 Query (org.hibernate.Query)7 Parameter (javax.persistence.Parameter)6 BigDecimal (java.math.BigDecimal)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 SQLQuery (org.hibernate.SQLQuery)4 ScrollableResults (org.hibernate.ScrollableResults)4 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 Date (java.util.Date)3 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)3