Package org.apache.openejb.jee.jpa.unit

Examples of org.apache.openejb.jee.jpa.unit.PersistenceUnit


        ejbJar.addEnterpriseBean(new StatelessBean(UserDAOChild.class));
        return ejbJar;
    }

    @Module public Persistence persistence() {
        PersistenceUnit unit = new PersistenceUnit("pu");
        unit.addClass(User.class);
        unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
        unit.setExcludeUnlistedClasses(true);

        Persistence persistence = new Persistence(unit);
        persistence.setVersion("2.0");
        return persistence;
    }
View Full Code Here


                        final Persistence persistence = (Persistence) obj;
                        appModule.getPersistenceModules().add(new PersistenceModule("", persistence));

                    } else if (obj instanceof PersistenceUnit) {

                        final PersistenceUnit unit = (PersistenceUnit) obj;
                        appModule.getPersistenceModules().add(new PersistenceModule("", new Persistence(unit)));

                    } else if (obj instanceof Beans) {

                        final Beans beans = (Beans) obj;
View Full Code Here

        assertSame(orangeJta, resources.get(0));
        assertSame(orangeNonJta, resources.get(1));
        assertSame(limeJta, resources.get(2));
        assertSame(limeNonJta, resources.get(3));

        PersistenceUnit unit1 = new PersistenceUnit("orange-unit");
        unit1.setJtaDataSource("Orange");
        unit1.setNonJtaDataSource("OrangeUnmanaged");

        PersistenceUnit unit2 = new PersistenceUnit("lime-unit");
        unit2.setJtaDataSource("Lime");
        unit2.setNonJtaDataSource("LimeUnmanaged");

        AppModule app = new AppModule(this.getClass().getClassLoader(), "test-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(unit1, unit2)));

        // Create app
View Full Code Here

    public void testFromWebAppIdThirdParty() throws Exception {
       
        ResourceInfo supplied = addDataSource("orange-id", OrangeDriver.class, "jdbc:orange-web:some:stuff", null);
        assertSame(supplied, resources.get(0));
       
        PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");

        ClassLoader cl = this.getClass().getClassLoader();
        AppModule app = new AppModule(cl, "orange-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(persistenceUnit)));
        WebApp webApp = new WebApp();
View Full Code Here

    public void testFromWebAppIdJta() throws Exception {
       
        ResourceInfo supplied = addDataSource("orange-id", OrangeDriver.class, "jdbc:orange-web:some:stuff", true);
        assertSame(supplied, resources.get(0));
       
        PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");

        ClassLoader cl = this.getClass().getClassLoader();
        AppModule app = new AppModule(cl, "orange-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(persistenceUnit)));
        WebApp webApp = new WebApp();
View Full Code Here

    public void testFromWebAppIdNonJta() throws Exception {
       
        ResourceInfo supplied = addDataSource("orange-id", OrangeDriver.class, "jdbc:orange-web:some:stuff", false);
        assertSame(supplied, resources.get(0));
       
        PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");

        ClassLoader cl = this.getClass().getClassLoader();
        AppModule app = new AppModule(cl, "orange-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(persistenceUnit)));
        WebApp webApp = new WebApp();
View Full Code Here

    public void testFromWebAppContextThirdParty() throws Exception {
       
        ResourceInfo supplied = addDataSource("orange-web", OrangeDriver.class, "jdbc:orange-web:some:stuff", null);
        assertSame(supplied, resources.get(0));
       
        PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");

        ClassLoader cl = this.getClass().getClassLoader();
        AppModule app = new AppModule(cl, "orange-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(persistenceUnit)));
        WebApp webApp = new WebApp();
View Full Code Here

    public void testFromWebAppContextJta() throws Exception {
       
        ResourceInfo supplied = addDataSource("orange-web", OrangeDriver.class, "jdbc:orange-web:some:stuff", true);
        assertSame(supplied, resources.get(0));
       
        PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");

        ClassLoader cl = this.getClass().getClassLoader();
        AppModule app = new AppModule(cl, "orange-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(persistenceUnit)));
        WebApp webApp = new WebApp();
View Full Code Here

    public void testFromWebAppContextNonJta() throws Exception {
       
        ResourceInfo supplied = addDataSource("orange-web", OrangeDriver.class, "jdbc:orange-web:some:stuff", false);
        assertSame(supplied, resources.get(0));
       
        PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");

        ClassLoader cl = this.getClass().getClassLoader();
        AppModule app = new AppModule(cl, "orange-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(persistenceUnit)));
        WebApp webApp = new WebApp();
View Full Code Here

    // --------------------------------------------------------------------------------------------
    //  Convenience methods
    // --------------------------------------------------------------------------------------------

    private PersistenceUnitInfo addPersistenceUnit(String unitName, String jtaDataSource, String nonJtaDataSource) throws OpenEJBException, IOException, NamingException {
        PersistenceUnit unit = new PersistenceUnit(unitName);
        unit.setJtaDataSource(jtaDataSource);
        unit.setNonJtaDataSource(nonJtaDataSource);

        AppModule app = new AppModule(this.getClass().getClassLoader(), unitName + "-app");
        app.getPersistenceModules().add(new PersistenceModule("root", new Persistence(unit)));

        // Create app
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.jpa.unit.PersistenceUnit

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.