Package org.hibernate.test.annotations

Examples of org.hibernate.test.annotations.Discount


  public void testSimpleOneToManyCollection() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount d = new Discount();
    d.setDiscount( 10 );
    Customer c = new Customer();
    List discounts = new ArrayList();
    discounts.add( d );
    d.setOwner( c );
    c.setDiscountTickets( discounts );
    s.persist( c );
    tx.commit();
    s.close();
View Full Code Here


  public void testCascade() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount discount = new Discount();
    discount.setDiscount( 20.12 );
    Customer customer = new Customer();
    Collection discounts = new ArrayList();
    discounts.add( discount );
    customer.setName( "Quentin Tarantino" );
    discount.setOwner( customer );
    customer.setDiscountTickets( discounts );
    s.persist( discount );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertEquals( 20.12, discount.getDiscount() );
    assertNotNull( discount.getOwner() );
    customer = new Customer();
    customer.setName( "Clooney" );
    discount.setOwner( customer );
    discounts = new ArrayList();
    discounts.add( discount );
    customer.setDiscountTickets( discounts );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertNotNull( discount.getOwner() );
    assertEquals( "Clooney", discount.getOwner().getName() );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
View Full Code Here

  public void testFetch() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount discount = new Discount();
    discount.setDiscount( 20 );
    Customer customer = new Customer();
    Collection discounts = new ArrayList();
    discounts.add( discount );
    customer.setName( "Quentin Tarantino" );
    discount.setOwner( customer );
    customer.setDiscountTickets( discounts );
    s.persist( discount );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
    tx.commit();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.load( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
    tx.commit();

    s = openSession();
    tx = s.beginTransaction();
    s.delete( s.get( Discount.class, discount.getId() ) );
    tx.commit();
    s.close();
  }
View Full Code Here

  public void testSimpleOneToManyCollection() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount d = new Discount();
    d.setDiscount( 10 );
    Customer c = new Customer();
    List discounts = new ArrayList();
    discounts.add( d );
    d.setOwner( c );
    c.setDiscountTickets( discounts );
    s.persist( c );
    tx.commit();
    s.close();
View Full Code Here

  public void testCascade() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount discount = new Discount();
    discount.setDiscount( 20.12 );
    Customer customer = new Customer();
    Collection discounts = new ArrayList();
    discounts.add( discount );
    customer.setName( "Quentin Tarantino" );
    discount.setOwner( customer );
    customer.setDiscountTickets( discounts );
    s.persist( discount );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertEquals( 20.12, discount.getDiscount() );
    assertNotNull( discount.getOwner() );
    customer = new Customer();
    customer.setName( "Clooney" );
    discount.setOwner( customer );
    discounts = new ArrayList();
    discounts.add( discount );
    customer.setDiscountTickets( discounts );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertNotNull( discount.getOwner() );
    assertEquals( "Clooney", discount.getOwner().getName() );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
View Full Code Here

  public void testFetch() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount discount = new Discount();
    discount.setDiscount( 20 );
    Customer customer = new Customer();
    Collection discounts = new ArrayList();
    discounts.add( discount );
    customer.setName( "Quentin Tarantino" );
    discount.setOwner( customer );
    customer.setDiscountTickets( discounts );
    s.persist( discount );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
    tx.commit();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.load( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
    tx.commit();

    s = openSession();
    tx = s.beginTransaction();
    s.delete( s.get( Discount.class, discount.getId() ) );
    tx.commit();
    s.close();
  }
View Full Code Here

  public void testCascade() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount discount = new Discount();
    discount.setDiscount( 20.12 );
    Customer customer = new Customer();
    Collection discounts = new ArrayList();
    discounts.add( discount );
    customer.setName( "Quentin Tarantino" );
    discount.setOwner( customer );
    customer.setDiscountTickets( discounts );
    s.persist( discount );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertEquals( 20.12, discount.getDiscount() );
    assertNotNull( discount.getOwner() );
    customer = new Customer();
    customer.setName( "Clooney" );
    discount.setOwner( customer );
    discounts = new ArrayList();
    discounts.add( discount );
    customer.setDiscountTickets( discounts );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertNotNull( discount.getOwner() );
    assertEquals( "Clooney", discount.getOwner().getName() );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
View Full Code Here

  public void testFetch() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount discount = new Discount();
    discount.setDiscount( 20 );
    Customer customer = new Customer();
    Collection discounts = new ArrayList();
    discounts.add( discount );
    customer.setName( "Quentin Tarantino" );
    discount.setOwner( customer );
    customer.setDiscountTickets( discounts );
    s.persist( discount );
    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.get( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
    tx.commit();

    s = openSession();
    tx = s.beginTransaction();
    discount = (Discount) s.load( Discount.class, discount.getId() );
    assertNotNull( discount );
    assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
    tx.commit();

    s = openSession();
    tx = s.beginTransaction();
    s.delete( s.get( Discount.class, discount.getId() ) );
    tx.commit();
    s.close();
  }
View Full Code Here

  public void testSimpleOneToManyCollection() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount d = new Discount();
    d.setDiscount( 10 );
    Customer c = new Customer();
    List discounts = new ArrayList();
    discounts.add( d );
    d.setOwner( c );
    c.setDiscountTickets( discounts );
    s.persist( c );
    tx.commit();
    s.close();
View Full Code Here

  public void testSimpleOneToManyCollection() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Discount d = new Discount();
    d.setDiscount( 10 );
    Customer c = new Customer();
    List discounts = new ArrayList();
    discounts.add( d );
    d.setOwner( c );
    c.setDiscountTickets( discounts );
    s.persist( c );
    tx.commit();
    s.close();
View Full Code Here

TOP

Related Classes of org.hibernate.test.annotations.Discount

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.