Package org.hibernate.test.dynamicentity

Examples of org.hibernate.test.dynamicentity.Customer


    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here


    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

    Session session = openSession();
    session.beginTransaction();
    Company company = ProxyHelper.newCompanyProxy();
    company.setName( "acme" );
    session.save( company );
    Customer customer = ProxyHelper.newCustomerProxy();
    customer.setName( "Steve" );
    customer.setCompany( company );
    Address address = ProxyHelper.newAddressProxy();
    address.setStreet( "somewhere over the rainbow" );
    address.setCity( "lawerence, kansas" );
    address.setPostalCode( "toto");
    customer.setAddress( address );
    customer.setFamily( new HashSet() );
    Person son = ProxyHelper.newPersonProxy();
    son.setName( "son" );
    customer.getFamily().add( son );
    Person wife = ProxyHelper.newPersonProxy();
    wife.setName( "wife" );
    customer.getFamily().add( wife );
    session.save( customer );
    session.getTransaction().commit();
    session.close();

    assertNotNull( "company id not assigned", company.getId() );
    assertNotNull( "customer id not assigned", customer.getId() );
    assertNotNull( "address id not assigned", address.getId() );
    assertNotNull( "son:Person id not assigned", son.getId() );
    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );

    session.refresh( customer );
    assertEquals( "name not updated", "other", customer.getName() );
    assertEquals( "company association not correct", "acme", customer.getCompany().getName() );

    session.getTransaction().commit();
    session.close();

    // Test detached entity re-attachment with these dyna-proxies
    customer.setName( "Steve" );
    session = openSession();
    session.beginTransaction();
    session.update( customer );
    session.flush();
    session.refresh( customer );
    assertEquals( "name not updated", "Steve", customer.getName() );
    session.getTransaction().commit();
    session.close();

    // Test querying
    session = openSession();
View Full Code Here

TOP

Related Classes of org.hibernate.test.dynamicentity.Customer

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.