Package tmp

Examples of tmp.Order


  @Test
  @Transactional
  public void testSaveOrderWithItems() throws Exception {
    Session session = sessionFactory.getCurrentSession();
    Order order = new Order();
    order.getItems().add(new Item());
    session.save(order);
    session.flush();
    assertNotNull(order.getId());
  }
View Full Code Here


  @Test
  @Transactional
  public void testSaveAndGet() throws Exception {
    Session session = sessionFactory.getCurrentSession();
    Order order = new Order();
    order.getItems().add(new Item());
    session.save(order);
    session.flush();
    // Otherwise the query returns the existing order (and we didn't set the
    // parent in the item)...
    session.clear();
    Order other = (Order) session.get(Order.class, order.getId());
    assertEquals(1, other.getItems().size());
    assertEquals(other, other.getItems().iterator().next().getOrder());
  }
View Full Code Here

  @Test
  @Transactional
  public void testSaveAndFind() throws Exception {
    Session session = sessionFactory.getCurrentSession();
    Order order = new Order();
    Item item = new Item();
    item.setProduct("foo");
    order.getItems().add(item);
    session.save(order);
    session.flush();
    // Otherwise the query returns the existing order (and we didn't set the
    // parent in the item)...
    session.clear();
    Order other = (Order) session
        .createQuery( "select o from Order o join o.items i where i.product=:product")
        .setString("product", "foo").uniqueResult();
    assertEquals(1, other.getItems().size());
    assertEquals(other, other.getItems().iterator().next().getOrder());
  }
View Full Code Here

TOP

Related Classes of tmp.Order

Copyright © 2018 www.massapicom. 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.