Package acceptance.hibernate.reference

Examples of acceptance.hibernate.reference.Division


    }

    protected void tearDown() {
        final Session session = getSessionFactory().getCurrentSession();
        session.beginTransaction();
        final Division div = (Division)session.createQuery("from Division").uniqueResult();
        session.delete(div);
        session.getTransaction().commit();
    }
View Full Code Here


        session.delete(div);
        session.getTransaction().commit();
    }

    public void testObjectGraphWithReferences() {
        final Division memory = setupNonpersistentDivision();
        final Division persisted = setupPersistentDivision();

        final String expectedXml = xstream.toXML(memory);
        final String persistedXml = xstream.toXML(persisted);

        final Session session = getSessionFactory().getCurrentSession();
        session.beginTransaction();
        final Division loaded = (Division)session.createQuery("from Division").uniqueResult();
        final String loadedXml = xstream.toXML(loaded);
        session.getTransaction().commit();
        assertEquals(expectedXml, persistedXml);
        assertEquals(expectedXml, loadedXml);
    }
View Full Code Here

    public void testLazyProxyWithReferences() {
        setupPersistentDivision();

        final Session session = getSessionFactory().getCurrentSession();
        session.beginTransaction();
        final Division loaded = (Division)session.createQuery("from Division").uniqueResult();
        final Department dept = (Department)loaded.getDepartments().iterator().next();
        final Person person = (Person)dept.getPeople().iterator().next();
        final Site site = person.getSite();
        assertTrue(HibernateProxy.class.isAssignableFrom(site.getClass()));
        final String loadedXml = xstream.toXML(site);
        session.getTransaction().commit();
View Full Code Here

     * Create the object within a Hibernate session and persist it.
     */
    private Division setupPersistentDivision() {
        final Session session = getSessionFactory().getCurrentSession();
        session.beginTransaction();
        final Division div = new Division("Div1");
        final Department dep = new Department("Dep1", div);
        final Site site = new Site("Site1");
        /*
         * This save is necessitated by the fact that Hibernate's transitive persistence is
         * depth-first and does not do a full graph analysis. Therefore it would be possible for
View Full Code Here

    /**
     * Create the object graph in-memory without Hibernate.
     */
    private Division setupNonpersistentDivision() {
        final Division div = new Division("Div1");
        final Department dep = new Department("Dep1", div);
        final Site site = new Site("Site1");
        new Person("Tom", dep, site);
        return div;
    }
View Full Code Here

     * Load object graph with Hibernate from the database.
     */
    private Division getPersistentDivision() {
        final Session session = getSessionFactory().getCurrentSession();
        session.beginTransaction();
        final Division div = (Division)session.createQuery("from Division").uniqueResult();
        session.getTransaction().commit();
        return div;
    }
View Full Code Here

TOP

Related Classes of acceptance.hibernate.reference.Division

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.