Package javax.persistence

Examples of javax.persistence.EntityManagerFactory.createEntityManager()


    factory = Persistence.createEntityManagerFactory( "manager1" );
  }

  public void testDefaultPar() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "defaultpar", new HashMap() );
    EntityManager em = emf.createEntityManager();
    ApplicationServer as = new ApplicationServer();
    as.setName( "JBoss AS" );
    Version v = new Version();
    v.setMajor( 4 );
    v.setMinor( 0 );
View Full Code Here


  public void testListenersDefaultPar() throws Exception {
    IncrementListener.reset();
    OtherIncrementListener.reset();
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "defaultpar", new HashMap() );
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    ApplicationServer as = new ApplicationServer();
    as.setName( "JBoss AS" );
    Version v = new Version();
    v.setMajor( 4 );
View Full Code Here

    emf.close();
  }

  public void testExplodedPar() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "explodedpar", new HashMap() );
    EntityManager em = emf.createEntityManager();
    org.hibernate.ejb.test.pack.explodedpar.Carpet carpet = new Carpet();
    Elephant el = new Elephant();
    el.setName( "Dumbo" );
    carpet.setCountry( "Turkey" );
    em.getTransaction().begin();
View Full Code Here

      nested = nested.getCause();
      if ( nested == null ) throw e;
      if ( ! ( nested instanceof ClassNotFoundException ) ) throw e;
      fail( "Try to process hbm file: " + e.getMessage() );
    }
    EntityManager em = emf.createEntityManager();
    Caipirinha s = new Caipirinha( "Strong" );
    em.getTransaction().begin();
    em.persist( s );
    em.getTransaction().commit();
View Full Code Here

    emf.close();
  }

  public void testCfgXmlPar() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "cfgxmlpar", new HashMap() );
    EntityManager em = emf.createEntityManager();
    Item i = new Item();
    i.setDescr( "Blah" );
    i.setName( "factory" );
    Morito m = new Morito();
    m.setPower( "SuperStrong" );
View Full Code Here

    emf.close();
  }

  public void testSpacePar() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "space par", new HashMap() );
    EntityManager em = emf.createEntityManager();
    Bug bug = new Bug();
    bug.setSubject( "Spaces in directory name don't play well on Windows");
    em.getTransaction().begin();
    em.persist( bug );
    em.flush();
View Full Code Here

    properties.put( "hibernate.connection.driver_class", "org.hsqldb.jdbcDriver" );
    properties.put( "hibernate.connection.username", "sa" );
    properties.put( "hibernate.connection.password", "" );
    properties.put( "hibernate.connection.url", "jdbc:hsqldb:." );
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "overridenpar", properties );
    EntityManager em = emf.createEntityManager();
    org.hibernate.ejb.test.pack.overridenpar.Bug bug = new org.hibernate.ejb.test.pack.overridenpar.Bug();
    bug.setSubject( "Allow DS overriding");
    em.getTransaction().begin();
    em.persist( bug );
    em.flush();
View Full Code Here

    emf.close();
  }

  public void testListenersOverridingCfgXmlPar() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "cfgxmlpar", new HashMap() );
    EntityManager em = emf.createEntityManager();
    Cat cat = new Cat();
    cat.setName( "123"); //validator catch that
    em.getTransaction().begin();
    try {
      em.persist( cat );
View Full Code Here

    ByteArrayInputStream byteIn = new ByteArrayInputStream( serialized );
    ObjectInputStream in = new ObjectInputStream( byteIn );
    EntityManagerFactory seriallizedFactory = (EntityManagerFactory) in.readObject();
    in.close();
    byteIn.close();
    EntityManager em = seriallizedFactory.createEntityManager();
    //em.getTransaction().begin();
    //em.setFlushMode( FlushModeType.NEVER );
    Cat cat = new Cat();
    cat.setAge( 3 );
    cat.setDateOfBirth( new Date() );
View Full Code Here

public class InterceptorTest extends TestCase {

  public void testInjectedInterceptor() {
    configuration.setInterceptor( new ExceptionInterceptor() );
    EntityManagerFactory emf = configuration.createEntityManagerFactory();
    EntityManager em = emf.createEntityManager();
    Item i = new Item();
    i.setName( "Laptop" );
    try {
      em.getTransaction().begin();
      em.persist( i );
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.