Package net.lr.tutorial.karaf.db.examplejpa.impl

Examples of net.lr.tutorial.karaf.db.examplejpa.impl.PersonServiceImpl


        InitialContext ic = new InitialContext();
        EmbeddedDataSource ds = new EmbeddedDataSource();
        ds.setDatabaseName("target/test");
        ds.setCreateDatabase("create");
        ic.bind("osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/derbyds)", ds);
        PersonServiceImpl personService = new PersonServiceImpl();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("personTest", System.getProperties());
        EntityManager em = emf.createEntityManager();
        personService.setEntityManager(em);
        em.getTransaction().begin();
        personService.deleteAll();
        personService.add(new Person("Christian Schneider", "@schneider_chris"));
        em.getTransaction().commit();
        List<Person> persons = personService.getAll();
        Assert.assertEquals(1, persons.size());
        Assert.assertEquals("Christian Schneider", persons.get(0).getName());
        Assert.assertEquals("@schneider_chris", persons.get(0).getTwitterName());
    }
View Full Code Here


        InitialContext ic = new InitialContext();
        EmbeddedDataSource ds = new EmbeddedDataSource();
        ds.setDatabaseName("target/test");
        ds.setCreateDatabase("create");
        ic.bind("osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/derbyds)", ds);
        PersonServiceImpl personService = new PersonServiceImpl();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("personTest", System.getProperties());
        EntityManager em = emf.createEntityManager();
        personService.setEntityManager(em);
        em.getTransaction().begin();
        personService.deleteAll();
        personService.add(new Person("Christian Schneider", "@schneider_chris"));
        em.getTransaction().commit();
        List<Person> persons = personService.getAll();
        Assert.assertEquals(1, persons.size());
        Assert.assertEquals("Christian Schneider", persons.get(0).getName());
        Assert.assertEquals("@schneider_chris", persons.get(0).getTwitterName());
    }
View Full Code Here

TOP

Related Classes of net.lr.tutorial.karaf.db.examplejpa.impl.PersonServiceImpl

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.