Meine Frage ist fast in diesen Thread geantwortet:Eclipseverbund Persistenzeinheiten auf verschiedenen Servern ohne <jar-file>
EclipseLink, EntityManager with two persistence units needed
Aber ich wurde mit einer Datei persistence.xml 3 Persistenzeinheiten zu erklären, und es funktionierte gut. Aber jetzt brauche ich eine zusammengesetzte Persistenzeinheit und ich weiß nicht und will keine separaten Gläser für jede Persistenzeinheit bauen. Gibt es eine Möglichkeit, dies ohne <jar-file>
Tag zu tun. Wenn nein, kann mir jemand ein Beispiel geben, wie man eine JAR-Datei mit einer einzelnen Persistenzeinheit erstellt?
EDIT 1: Diese Konfiguration ich mit endete, aber es funktioniert immer noch nicht - alles, was ich bekommen diese Ausgabe ist und wenn ich versuche, em.createNamedQuery zu verwenden (Hexe gearbeitet, bevor, wenn ich seperate Persistenzeinheiten hatte) nichts passiert der Code stoppt auf createEntity Linie und das ist es.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.composite-unit" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="Minutis" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>database.entity.Entity1</class>
<class>database.entity.Entity2</class>
...
<properties>
<property name="eclipselink.composite-unit.member" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="Minutis2" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>database.entity.EEntity1</class>
<class>database.entity.EEntity2</class>
...
<properties>
<property name="eclipselink.composite-unit.member" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="Minutis3" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>database.entity.EEEntity1</class>
<class>database.entity.EEEntity2</class>
...
<properties>
<property name="eclipselink.composite-unit.member" value="true"/>
</properties>
</persistence-unit>
</persistence>
Dies ist, wie EntityManager
erstellt:
Map minutis = new HashMap();
minutis.put("javax.persistence.jdbc.user", "user");
minutis.put("javax.persistence.jdbc.password", "password");
minutis.put("javax.persistence.jdbc.driver", "driver");
minutis.put("javax.persistence.jdbc.url", "url");
Map minutis2= new HashMap();
minutis2.put("javax.persistence.jdbc.user", "user");
minutis2.put("javax.persistence.jdbc.password", "password");
minutis2.put("javax.persistence.jdbc.driver", "driver");
minutis2.put("javax.persistence.jdbc.url", "url");
Map minutis3= new HashMap();
minutis3.put("javax.persistence.jdbc.user", "user");
minutis3.put("javax.persistence.jdbc.password", "password");
minutis3.put("javax.persistence.jdbc.driver", "driver");
minutis3.put("javax.persistence.jdbc.url", "url");
Map persistanceUnitsProps = new HashMap();
persistanceUnitsProps.put("Minutis", minutis);
persistanceUnitsProps.put("Minutis2", minutis2);
persistanceUnitsProps.put("Minutis3", minutis3);
Map props = new HashMap();
props.put("eclipselink.logging.level", "FINEST");
props.put("eclipselink.composite-unit.properties", persistanceUnitsProps);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistenceUnit", props);
em = emf.createEntityManager();
Und hier ist eine Ausgabe, die ich bekommen:
run:
[EL Finest]: 2012-10-09 09:04:43.071--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--Begin predeploying Persistence Unit persistenceUnit; session file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit; state Initial; factoryCount 0
[EL Finest]: 2012-10-09 09:04:43.099--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finest]: 2012-10-09 09:04:43.116--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--End predeploying Persistence Unit persistenceUnit; session file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit; state Predeployed; factoryCount 0
[EL Finer]: 2012-10-09 09:04:43.117--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--JavaSECMPInitializer - transformer is null.
[EL Finest]: 2012-10-09 09:04:43.117--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--Begin predeploying Persistence Unit persistenceUnit; session file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit; state Predeployed; factoryCount 0
[EL Finest]: 2012-10-09 09:04:43.117--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--End predeploying Persistence Unit persistenceUnit; session file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit; state Predeployed; factoryCount 1
[EL Finest]: 2012-10-09 09:04:43.125--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--Begin deploying Persistence Unit persistenceUnit; session file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit; state Predeployed; factoryCount 1
[EL Finest]: 2012-10-09 09:04:43.128--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--property=eclipselink.logging.level; value=FINEST
[EL Finest]: 2012-10-09 09:04:43.128--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--property=eclipselink.logging.level; value=FINEST
[EL Info]: 2012-10-09 09:04:43.13--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Info]: 2012-10-09 09:04:43.138--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit login successful
[EL Warning]: 2012-10-09 09:04:43.146--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
[EL Finer]: 2012-10-09 09:04:43.146--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
[EL Finest]: 2012-10-09 09:04:43.147--SessionBroker(2079047885)--Thread(Thread[SwingWorker-pool-1-thread-1,5,main])--End deploying Persistence Unit persistenceUnit; session file:/C:/Users/Minutis/Documents/NetBeansProjects/JavaApplication4/build/classes/_persistenceUnit; state Deployed; factoryCount 1
EDIT 2:
Ich dachte, dass das Problem ist, dass Persistenz-Einheit keine Entitäten sehen, obwohl ich sie mit Klassen-Tags deklariere ... Irgendwelche Hilfe dabei?
Irgendwelche Hilfe zu diesem Thema? – Minutis
Haben Sie herausgefunden, wie Sie Composite Persistence Unit mit einer einzelnen Datei persistence.xml verwenden können? –