Package org.hibernate.test.instrument.domain

Examples of org.hibernate.test.instrument.domain.Folder


    Transaction t = s.beginTransaction();
    final double SIZE_IN_KB = 20480;
    final double SIZE_IN_MB = SIZE_IN_KB / 1024d;
    Owner o = new Owner();
    Document doc = new Document();
    Folder fol = new Folder();
    o.setName("gavin");
    doc.setName("Hibernate in Action");
    doc.setSummary("blah");
    doc.updateText("blah blah")
    fol.setName("books");
    doc.setOwner(o);
    doc.setFolder(fol);
    doc.setSizeKb(SIZE_IN_KB);
    fol.getDocuments().add(doc);
    s.persist(o);
    s.persist(fol);
    t.commit();
    s.close();
View Full Code Here


    SessionFactory factory = getFactory();
    Session s = factory.openSession();
    Transaction t = s.beginTransaction();
    Owner o = new Owner();
    Document doc = new Document();
    Folder fol = new Folder();
    o.setName("gavin");
    doc.setName("Hibernate in Action");
    doc.setSummary("blah");
    doc.updateText("blah blah");
    fol.setName("books");
    doc.setOwner(o);
    doc.setFolder(fol);
    fol.getDocuments().add(doc);
    s.save(o);
    s.save(fol);
    t.commit();
    s.close();
View Full Code Here

  public void execute() {
    Session s = getFactory().openSession();
    Transaction t = s.beginTransaction();
    Owner gavin = new Owner();
    Document hia = new Document();
    Folder fol = new Folder();
    gavin.setName("gavin");
    hia.setName("Hibernate in Action");
    hia.setSummary("blah");
    hia.updateText("blah blah");
    fol.setName("books");
    hia.setOwner(gavin);
    hia.setFolder(fol);
    fol.getDocuments().add(hia);
    s.persist(gavin);
    s.persist(fol);
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertEquals( hia.getFolder().getClass(), Folder.class);
    fol = hia.getFolder();
    Assert.assertTrue( Hibernate.isInitialized(fol) );
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertSame( hia.getFolder(), s.load(Folder.class, fol.getId()) );
    Assert.assertTrue( Hibernate.isInitialized( hia.getFolder() ) );
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    fol = (Folder) s.get(Folder.class, fol.getId());
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertSame( fol, hia.getFolder() );
    fol = hia.getFolder();
    Assert.assertTrue( Hibernate.isInitialized(fol) );
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    fol = (Folder) s.load(Folder.class, fol.getId());
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertNotSame( fol, hia.getFolder() );
    fol = hia.getFolder();
    Assert.assertTrue( Hibernate.isInitialized(fol) );
    s.delete(hia.getFolder());
View Full Code Here

  public void execute() {
    Session s = getFactory().openSession();
    Transaction t = s.beginTransaction();
    Owner o = new Owner();
    Document doc = new Document();
    Folder fol = new Folder();
    o.setName("gavin");
    doc.setName("Hibernate in Action");
    doc.setSummary("blah");
    doc.updateText("blah blah");
    fol.setName("books");
    doc.setOwner(o);
    doc.setFolder(fol);
    fol.getDocuments().add(doc);
    s.persist(o);
    s.persist(fol);
    t.commit();
    s.close();
View Full Code Here

  public void execute() {
    Session s = getFactory().openSession();
    Transaction t = s.beginTransaction();
    Owner o = new Owner();
    Document doc = new Document();
    Folder fol = new Folder();
    o.setName("gavin");
    doc.setName("Hibernate in Action");
    doc.setSummary("blah");
    doc.updateText("blah blah");
    fol.setName("books");
    doc.setOwner(o);
    doc.setFolder(fol);
    fol.getDocuments().add(doc);
    Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
    s.persist(o);
    s.persist(fol);
    t.commit();
    s.close();
View Full Code Here

    SessionFactory factory = getFactory();
    Session s = factory.openSession();
    Transaction t = s.beginTransaction();
    Owner o = new Owner();
    Document doc = new Document();
    Folder fol = new Folder();
    o.setName("gavin");
    doc.setName("Hibernate in Action");
    doc.setSummary("blah");
    doc.updateText("blah blah");
    fol.setName("books");
    doc.setOwner(o);
    doc.setFolder(fol);
    fol.getDocuments().add(doc);
    s.save(o);
    s.save(fol);
    t.commit();
    s.close();
View Full Code Here

*/
public class TestDirtyCheckExecutable extends AbstractExecutable {
  public void execute() {
    Session s = getFactory().openSession();
    Transaction t = s.beginTransaction();
    Folder pics = new Folder();
    pics.setName("pics");
    Folder docs = new Folder();
    docs.setName("docs");
    s.persist(docs);
    s.persist(pics);
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    List list = s.createCriteria(Folder.class).list();
    for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
      Folder f = (Folder) iter.next();
      Assert.assertFalse( f.nameWasread );
    }
    t.commit();
    s.close();

    for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
      Folder f = (Folder) iter.next();
      Assert.assertFalse( f.nameWasread );
    }

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

  public void execute() {
    Session s = getFactory().openSession();
    Transaction t = s.beginTransaction();
    Owner gavin = new Owner();
    Document hia = new Document();
    Folder fol = new Folder();
    gavin.setName("gavin");
    hia.setName("Hibernate in Action");
    hia.setSummary("blah");
    hia.updateText("blah blah");
    fol.setName("books");
    hia.setOwner(gavin);
    hia.setFolder(fol);
    fol.getDocuments().add(hia);
    s.persist(gavin);
    s.persist(fol);
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertEquals( hia.getFolder().getClass(), Folder.class);
    fol = hia.getFolder();
    Assert.assertTrue( Hibernate.isInitialized(fol) );
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertSame( hia.getFolder(), s.load(Folder.class, fol.getId()) );
    Assert.assertTrue( Hibernate.isInitialized( hia.getFolder() ) );
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    fol = (Folder) s.get(Folder.class, fol.getId());
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertSame( fol, hia.getFolder() );
    fol = hia.getFolder();
    Assert.assertTrue( Hibernate.isInitialized(fol) );
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    fol = (Folder) s.load(Folder.class, fol.getId());
    hia = (Document) s.createCriteria(Document.class).uniqueResult();
    Assert.assertNotSame( fol, hia.getFolder() );
    fol = hia.getFolder();
    Assert.assertTrue( Hibernate.isInitialized(fol) );
    s.delete(hia.getFolder());
View Full Code Here

    SessionFactory factory = getFactory();
    Session s = factory.openSession();
    Transaction t = s.beginTransaction();
    Owner o = new Owner();
    Document doc = new Document();
    Folder fol = new Folder();
    o.setName("gavin");
    doc.setName("Hibernate in Action");
    doc.setSummary("blah");
    doc.updateText("blah blah");
    fol.setName("books");
    doc.setOwner(o);
    doc.setFolder(fol);
    fol.getDocuments().add(doc);
    s.save(o);
    s.save(fol);
    t.commit();
    s.close();
View Full Code Here

*/
public class TestDirtyCheckExecutable extends AbstractExecutable {
  public void execute() {
    Session s = getFactory().openSession();
    Transaction t = s.beginTransaction();
    Folder pics = new Folder();
    pics.setName("pics");
    Folder docs = new Folder();
    docs.setName("docs");
    s.persist(docs);
    s.persist(pics);
    t.commit();
    s.close();

    s = getFactory().openSession();
    t = s.beginTransaction();
    List list = s.createCriteria(Folder.class).list();
    for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
      Folder f = (Folder) iter.next();
      Assert.assertFalse( f.nameWasread );
    }
    t.commit();
    s.close();

    for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
      Folder f = (Folder) iter.next();
      Assert.assertFalse( f.nameWasread );
    }

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

TOP

Related Classes of org.hibernate.test.instrument.domain.Folder

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.