Search in sources :

Example 36 with SkipForDialect

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

the class ASTParserLoadingTest method testPaginationWithPolymorphicQuery.

@Test
@SkipForDialect(value = IngresDialect.class, jiraKey = "HHH-4961", comment = "Ingres does not support this scoping in 9.3")
public void testPaginationWithPolymorphicQuery() {
    Session s = openSession();
    s.beginTransaction();
    Human h = new Human();
    h.setName(new Name("Steve", null, "Ebersole"));
    s.save(h);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    List results = s.createQuery("from java.lang.Object").setMaxResults(2).list();
    assertEquals(1, results.size());
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    s.delete(h);
    s.getTransaction().commit();
    s.close();
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 37 with SkipForDialect

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

the class ASTParserLoadingTest method testOneToManyFilter.

@Test
@SkipForDialect(value = IngresDialect.class, jiraKey = "HHH-4976", comment = "Ingres 9.3 does not support sub-selects in the select list")
public void testOneToManyFilter() throws Throwable {
    Session session = openSession();
    Transaction txn = session.beginTransaction();
    Product product = new Product();
    product.setDescription("My Product");
    product.setNumberAvailable(10);
    product.setPrice(new BigDecimal(123));
    product.setProductId("4321");
    session.save(product);
    Customer customer = new Customer();
    customer.setCustomerId("123456789");
    customer.setName("My customer");
    customer.setAddress("somewhere");
    session.save(customer);
    Order order = customer.generateNewOrder(new BigDecimal(1234));
    session.save(order);
    LineItem li = order.generateLineItem(product, 5);
    session.save(li);
    session.flush();
    assertEquals(session.createFilter(customer.getOrders(), "").list().size(), 1);
    assertEquals(session.createFilter(order.getLineItems(), "").list().size(), 1);
    assertEquals(session.createFilter(order.getLineItems(), "where this.quantity > :quantity").setInteger("quantity", 5).list().size(), 0);
    session.delete(li);
    session.delete(order);
    session.delete(product);
    session.delete(customer);
    txn.commit();
    session.close();
}
Also used : Order(org.hibernate.test.cid.Order) Transaction(org.hibernate.Transaction) Customer(org.hibernate.test.cid.Customer) Product(org.hibernate.test.cid.Product) LineItem(org.hibernate.test.cid.LineItem) BigDecimal(java.math.BigDecimal) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 38 with SkipForDialect

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

the class ASTParserLoadingTest method testSelectClauseSubselect.

@Test
@SkipForDialect(value = IngresDialect.class, jiraKey = "HHH-4973", comment = "Ingres 9.3 does not support sub-selects in the select list")
@SuppressWarnings({ "unchecked" })
public void testSelectClauseSubselect() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Zoo zoo = new Zoo();
    zoo.setName("Melbourne Zoo");
    zoo.setMammals(new HashMap());
    zoo.setAnimals(new HashMap());
    Mammal plat = new Mammal();
    plat.setBodyWeight(11f);
    plat.setDescription("Platypus");
    plat.setZoo(zoo);
    plat.setSerialNumber("plat123");
    zoo.getMammals().put("Platypus", plat);
    zoo.getAnimals().put("plat123", plat);
    s.persist(plat);
    s.persist(zoo);
    s.createQuery("select (select max(z.id) from a.zoo z) from Animal a").list();
    s.createQuery("select (select max(z.id) from a.zoo z where z.name=:name) from Animal a").setParameter("name", "Melbourne Zoo").list();
    s.delete(plat);
    s.delete(zoo);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) HashMap(java.util.HashMap) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 39 with SkipForDialect

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

the class ASTParserLoadingTest method testParameterMixing.

@Test
@SkipForDialect(value = CUBRIDDialect.class, comment = "As of version 8.4.1 CUBRID does not support temporary tables." + " This test somehow calls MultiTableDeleteExecutor which raises an" + " exception saying 'cannot doAfterTransactionCompletion multi-table" + " deletes using dialect not supporting temp tables'.")
public void testParameterMixing() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    s.createQuery("from Animal a where a.description = ? and a.bodyWeight = ? or a.bodyWeight = :bw").setString(0, "something").setFloat(1, 12345f).setFloat("bw", 123f).list();
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 40 with SkipForDialect

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

the class BulkManipulationTest method testTempTableGenerationIsolation.

@Test
@SkipForDialect(value = CUBRIDDialect.class, comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" + "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables")
public void testTempTableGenerationIsolation() throws Throwable {
    Session s = openSession();
    s.beginTransaction();
    Truck truck = new Truck();
    truck.setVin("123t");
    truck.setOwner("Steve");
    s.save(truck);
    // manually flush the session to ensure the insert happens
    s.flush();
    // now issue a bulk delete against Car which should force the temp table to be
    // created.  we need to test to ensure that this does not cause the transaction
    // to be committed...
    s.createQuery("delete from Vehicle").executeUpdate();
    s.getTransaction().rollback();
    s.close();
    s = openSession();
    s.beginTransaction();
    List list = s.createQuery("from Car").list();
    assertEquals("temp table gen caused premature commit", 0, list.size());
    s.createQuery("delete from Car").executeUpdate();
    s.getTransaction().rollback();
    s.close();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Session(org.hibernate.Session) 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