Examples of Cat


Examples of org.hibernate.ejb.test.Cat

  }


  public void testPostPersist() throws Exception {
    EntityManager em = getOrCreateEntityManager();
    Cat c = new Cat();
    em.getTransaction().begin();
    c.setLength( 23 );
    c.setAge( 2 );
    c.setName( "Beetle" );
    c.setDateOfBirth( new Date() );
    em.persist( c );
    em.getTransaction().commit();
    em.close();
    List ids = c.getIdList();
    Object id = c.getIdList().get( ids.size() - 1 );
    assertNotNull( id );
  }
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

    in.close();
    byteIn.close();
    EntityManager em = serializedFactory.createEntityManager();
    //em.getTransaction().begin();
    //em.setFlushMode( FlushModeType.NEVER );
    Cat cat = new Cat();
    cat.setAge( 3 );
    cat.setDateOfBirth( new Date() );
    cat.setLength( 22 );
    cat.setName( "Kitty" );
    em.persist( cat );
    Item item = new Item();
    item.setName( "Train Ticket" );
    item.setDescr( "Paris-London" );
    em.persist( item );
    //em.getTransaction().commit();
    //em.getTransaction().begin();
    item.setDescr( "Paris-Bruxelles" );
    //em.getTransaction().commit();

    //fake the in container work
    ( (HibernateEntityManager) em ).getSession().disconnect();
    stream = new ByteArrayOutputStream();
    out = new ObjectOutputStream( stream );
    out.writeObject( em );
    out.close();
    serialized = stream.toByteArray();
    stream.close();
    byteIn = new ByteArrayInputStream( serialized );
    in = new ObjectInputStream( byteIn );
    em = (EntityManager) in.readObject();
    in.close();
    byteIn.close();
    //fake the in container work
    em.getTransaction().begin();
    item = em.find( Item.class, item.getName() );
    item.setDescr( item.getDescr() + "-Amsterdam" );
    cat = (Cat) em.createQuery( "select c from " + Cat.class.getName() + " c" ).getSingleResult();
    cat.setLength( 34 );
    em.flush();
    em.remove( item );
    em.remove( cat );
    em.flush();
    em.getTransaction().commit();
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

    conf.addAnnotatedClass( Cat.class );
    conf.addAnnotatedClass( Kitten.class );
    conf.addProperties(getProperties());
    EntityManagerFactory emf = conf.buildEntityManagerFactory();
    EntityManager em = emf.createEntityManager();
    Cat cat = new Cat();
    cat.setAge( 23 );
    cat.setDateOfBirth( new Date() );
    cat.setLength( 32 );
    cat.setName( "Tomy" );
    em.getTransaction().begin();
    em.persist( cat );
    em.flush();
    assertNotNull( em.find(Cat.class, cat.getId() ) );
    em.getTransaction().rollback();
    emf.close();
  }
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

    Ejb3Configuration conf = new Ejb3Configuration();
    conf.configure( "org/hibernate/ejb/test/ejb3configuration/hibernate.cfg.xml" );
    conf.addProperties(getProperties());
    EntityManagerFactory emf = conf.buildEntityManagerFactory();
    EntityManager em = emf.createEntityManager();
    Cat cat = new Cat();
    cat.setAge( 23 );
    cat.setDateOfBirth( new Date() );
    cat.setLength( 32 );
    cat.setName( "Tomy" );
    em.getTransaction().begin();
    em.persist( cat );
    em.flush();
    assertNotNull( em.find(Cat.class, cat.getId() ) );
    em.getTransaction().rollback();
    emf.close();
  }
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

@SuppressWarnings("unchecked")
public class CallbacksTest extends TestCase {

  public void testCallbackMethod() throws Exception {
    EntityManager em = getOrCreateEntityManager();
    Cat c = new Cat();
    c.setName( "Kitty" );
    c.setDateOfBirth( new Date( 90, 11, 15 ) );
    em.getTransaction().begin();
    em.persist( c );
    em.getTransaction().commit();
    em.clear();
    em.getTransaction().begin();
    c = em.find( Cat.class, c.getId() );
    assertFalse( c.getAge() == 0 );
    c.setName( "Tomcat" ); //update this entity
    em.getTransaction().commit();
    em.clear();
    em.getTransaction().begin();
    c = em.find( Cat.class, c.getId() );
    assertEquals( "Tomcat", c.getName() );
    em.getTransaction().commit();
    em.close();
  }
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

    em.close();
  }

  public void testEntityListener() throws Exception {
    EntityManager em = getOrCreateEntityManager();
    Cat c = new Cat();
    c.setName( "Kitty" );
    c.setLength( 12 );
    c.setDateOfBirth( new Date( 90, 11, 15 ) );
    em.getTransaction().begin();
    int previousVersion = c.getManualVersion();
    em.persist( c );
    em.getTransaction().commit();
    em.getTransaction().begin();
    c = em.find( Cat.class, c.getId() );
    assertNotNull( c.getLastUpdate() );
    assertTrue( previousVersion < c.getManualVersion() );
    assertEquals( 12, c.getLength() );
    previousVersion = c.getManualVersion();
    c.setName( "new name" );
    em.getTransaction().commit();
    em.getTransaction().begin();
    c = em.find( Cat.class, c.getId() );
    assertTrue( previousVersion < c.getManualVersion() );
    em.getTransaction().commit();

    em.close();
  }
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

  }


  public void testPostPersist() throws Exception {
    EntityManager em = getOrCreateEntityManager();
    Cat c = new Cat();
    em.getTransaction().begin();
    c.setLength( 23 );
    c.setAge( 2 );
    c.setName( "Beetle" );
    c.setDateOfBirth( new Date() );
    em.persist( c );
    em.getTransaction().commit();
    em.close();
    List ids = Cat.getIdList();
    Object id = Cat.getIdList().get( ids.size() - 1 );
View Full Code Here

Examples of org.hibernate.ejb.test.Cat

 
  @FailureExpected(message = "collection change does not trigger an event", jiraKey = "EJB-288")
  public void testPostUpdateCollection() throws Exception {
    // create a cat
    EntityManager em = getOrCreateEntityManager();
    Cat cat = new Cat();
    em.getTransaction().begin();
    cat.setLength( 23 );
    cat.setAge( 2 );
    cat.setName( "Beetle" );
    cat.setDateOfBirth( new Date() );
    em.persist( cat );
    em.getTransaction().commit();

    // assert it is persisted
    List ids = Cat.getIdList();
    Object id = Cat.getIdList().get( ids.size() - 1 );
    assertNotNull( id );

    // add a kitten to the cat - triggers PostCollectionRecreateEvent
    int postVersion = Cat.postVersion;
    em.getTransaction().begin();
    Kitten kitty = new Kitten();
    kitty.setName("kitty");
    List kittens = new ArrayList<Kitten>();
    kittens.add(kitty);
    cat.setKittens(kittens);
    em.getTransaction().commit();
    assertEquals("Post version should have been incremented.", postVersion + 1, Cat.postVersion);

    // add another kitten - triggers PostCollectionUpdateEvent.
    postVersion = Cat.postVersion;
    em.getTransaction().begin();
    Kitten tom = new Kitten();
    tom.setName("Tom");
    cat.getKittens().add(tom);
    em.getTransaction().commit();
    assertEquals("Post version should have been incremented.", postVersion + 1, Cat.postVersion);

    // delete a kitty - triggers PostCollectionUpdateEvent
    postVersion = Cat.postVersion;
    em.getTransaction().begin();
    cat.getKittens().remove(tom);
    em.getTransaction().commit();
    assertEquals("Post version should have been incremented.", postVersion + 1, Cat.postVersion);

    // delete and recreate kittens - triggers PostCollectionRemoveEvent and PostCollectionRecreateEvent)
    postVersion = Cat.postVersion;
    em.getTransaction().begin();
    cat.setKittens(new ArrayList<Kitten>());
    em.getTransaction().commit();
    assertEquals("Post version should have been incremented.", postVersion + 2, Cat.postVersion);

    em.close();
  }
View Full Code Here

Examples of org.qi4j.test.indexing.model.Cat

                NameableAssert.trace( jackDoe );
            }

            {
                EntityBuilder<CatEntity> catBuilder = unitOfWork.newEntityBuilder( CatEntity.class );
                Cat felix = catBuilder.instance();
                felix.name().set( "Felix" );
                catBuilder.newInstance();
            }
            unitOfWork.complete();
        }
    }
View Full Code Here

Examples of prolog.core.Cat

    int v=10;
    int e0=5;
    int e=10;
    int g=0;
    int m=15;
    Cat RG=
      Params.randomRanked(seed,v0,v,e0,e,g,m);
    return RG;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.