Search in sources :

Example 1 with Id

use of org.hibernate.test.cid.LineItem.Id in project hibernate-orm by hibernate.

the class ASTParserLoadingTest method testComponentParameterBinding.

@Test
@TestForIssue(jiraKey = "HHH-1774")
@SkipForDialect(value = IngresDialect.class, comment = "Subselects are not supported within select target lists in Ingres", jiraKey = "HHH-4970")
public void testComponentParameterBinding() {
    Session s = openSession();
    s.beginTransaction();
    Order.Id oId = new Order.Id("1234", 1);
    // control
    s.createQuery("from Order o where o.customer.name =:name and o.id = :id").setParameter("name", "oracle").setParameter("id", oId).list();
    // this is the form that caused problems in the original case...
    s.createQuery("from Order o where o.id = :id and o.customer.name =:name ").setParameter("id", oId).setParameter("name", "oracle").list();
    s.getTransaction().commit();
    s.close();
}
Also used : Order(org.hibernate.test.cid.Order) Id(org.hibernate.test.cid.LineItem.Id) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 2 with Id

use of org.hibernate.test.cid.LineItem.Id in project hibernate-orm by hibernate.

the class ASTParserLoadingTest method testRowValueConstructorSyntaxInInList.

@Test
public void testRowValueConstructorSyntaxInInList() {
    Session s = openSession();
    s.beginTransaction();
    Product product = new Product();
    product.setDescription("My Product");
    product.setNumberAvailable(10);
    product.setPrice(new BigDecimal(123));
    product.setProductId("4321");
    s.save(product);
    Customer customer = new Customer();
    customer.setCustomerId("123456789");
    customer.setName("My customer");
    customer.setAddress("somewhere");
    s.save(customer);
    Order order = customer.generateNewOrder(new BigDecimal(1234));
    s.save(order);
    LineItem li = order.generateLineItem(product, 5);
    s.save(li);
    product = new Product();
    product.setDescription("My Product");
    product.setNumberAvailable(10);
    product.setPrice(new BigDecimal(123));
    product.setProductId("1234");
    s.save(product);
    li = order.generateLineItem(product, 10);
    s.save(li);
    s.flush();
    Query query = s.createQuery("from LineItem l where l.id in (:idList)");
    List<Id> list = new ArrayList<Id>();
    list.add(new Id("123456789", order.getId().getOrderNumber(), "4321"));
    list.add(new Id("123456789", order.getId().getOrderNumber(), "1234"));
    query.setParameterList("idList", list);
    assertEquals(2, query.list().size());
    query = s.createQuery("from LineItem l where l.id in :idList");
    query.setParameterList("idList", list);
    assertEquals(2, query.list().size());
    s.getTransaction().rollback();
    s.close();
}
Also used : Order(org.hibernate.test.cid.Order) Query(org.hibernate.Query) Customer(org.hibernate.test.cid.Customer) ArrayList(java.util.ArrayList) Product(org.hibernate.test.cid.Product) LineItem(org.hibernate.test.cid.LineItem) Id(org.hibernate.test.cid.LineItem.Id) BigDecimal(java.math.BigDecimal) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

Session (org.hibernate.Session)2 Id (org.hibernate.test.cid.LineItem.Id)2 Order (org.hibernate.test.cid.Order)2 Test (org.junit.Test)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Query (org.hibernate.Query)1 Customer (org.hibernate.test.cid.Customer)1 LineItem (org.hibernate.test.cid.LineItem)1 Product (org.hibernate.test.cid.Product)1 SkipForDialect (org.hibernate.testing.SkipForDialect)1 TestForIssue (org.hibernate.testing.TestForIssue)1