persistence-unit

How can I merge / extend persistence units from different JARs?

自闭症网瘾萝莉.ら 提交于 2020-01-11 01:09:07
问题 I use JPA persistence for my data models with Eclipselink as the persistence provider. I have a modular (OSGi) application and one of the modules contains the standard data model and a persistence unit that automatically includes all the entities from the package. The persistence provider is in another module, which works well. Now I want a third module to add some entities to the persistence unit. How do I do that? I found this solution, which seems specific to Spring which I'm not using.

Entity unknown in EAR with persistence unit in another jar

痴心易碎 提交于 2020-01-06 15:53:06
问题 I'have an EAR with a WAR module, some EJB modules and some JARS, for instance: EAR - moduleEjb.jar - moduleWeb.war -lib - entity.jar - resource.jar I want to use persistence units from the resource.jar so the ejb modules are independent from the environment (i must remember only PU name, i can change the jndi for the datasource in resource.jar without change moduleEjb.jar), but the entities are not found. The entity is in entity.jar: @Entity @Table(name = "ttracciatikettle", indexes = {...})

EJB3 - using 2 persistence units within a transaction (Exception: Local transaction already has 1 non-XA Resource)

烂漫一生 提交于 2020-01-01 02:45:28
问题 I am trying to use 2 persistence units within the same transaction in a Java EE application deployed on Glassfish. The 2 persistence units are defined in persistence.xml, as follows: <persistence-unit name="BeachWater"> <jta-data-source>jdbc/BeachWater</jta-data-source> ... <persistence-unit name="LIMS"> <jta-data-source>jdbc/BeachWaterLIMS</jta-data-source> ... These persistence units correspond to JDBC resources and connection pools which I had defined in Glassfish as follows (include one

How to execute differnet import.sql in Hibernate/JPA for each persistence unit?

时光怂恿深爱的人放手 提交于 2019-12-18 12:42:34
问题 I have configured two persistence units in my JPA/Hibernate configuration. Now i need to execute different import.sql for each persistence unit. How can I specify which import.sql should be executed for each persistence unit? According Hibernate to documentation, I should place import.sql in classpath. If I do that, import.sql is executed on each persistence unit. I need somehow to specify different import.sql for each persistence unit. 回答1: You could probably do something manual using the

JPA Entity - Specify Persistence Unit?

北城以北 提交于 2019-12-18 02:49:07
问题 I have a JavaEE project that makes use of multiple persistence units. Is there any way to specify which persistence unit a particular JPA Entity belongs to? Some entities are in one data source, while others are in my second data source. Is there a way to differentiate between the two using annotations? 回答1: To specify which persistent unit an Entity belongs to, use the persistence.xml file: <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org

use of EntityManagerFactory causing duplicate primary key exceptions

谁说胖子不能爱 提交于 2019-12-12 05:11:13
问题 Hey guys, my goal is create an EntityManager using properties dependent on which database is in use. I've seen something like this done in all my Google searches(I made the code more basic for the purpose of this question): @PersistenceUnit private EntityManagerFactory emf; private EntityManager em; private Properties props; @PostConstruct public void createEntityManager(){ //if oracle set oracle properties else set postgres properties emf = Persistence.createEntityManagerFactory("app-x"); em

Glassfish Deployment out of Eclipse Helios SR2 fails

淺唱寂寞╮ 提交于 2019-12-08 08:03:51
问题 I experience a strange Exception which occurs when I try to deploy my Java EE application out of the latest Eclipse version (Helios SR2 with the Glassfish adapter version 1.7.1) to the latest Glassfish (3.1). If I deploy the war file manually to the server via the admin console everything works fine. So there does not seem to by a bug in the application itself or in the Glassfish config: SCHWERWIEGEND: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [com

Create Entity Manager Factory without persistence.xml

左心房为你撑大大i 提交于 2019-12-06 10:46:33
问题 Is there a way to create the EntityManagerFactory without a persistence unit defined ? Can you give all the required properties to create an entity manager factory? I need to create the EntityManagerFactory from the user's specified values at runtime. Updating the persistence.xml and recompiling is not an option. Currently I am using eclipselink dynamic persistence so i need to create the EntityManagerFactory without a persistence unit defined ? I have groups of runtime entities that need to

EJB3 - using 2 persistence units within a transaction (Exception: Local transaction already has 1 non-XA Resource)

杀马特。学长 韩版系。学妹 提交于 2019-12-03 06:30:21
I am trying to use 2 persistence units within the same transaction in a Java EE application deployed on Glassfish. The 2 persistence units are defined in persistence.xml, as follows: <persistence-unit name="BeachWater"> <jta-data-source>jdbc/BeachWater</jta-data-source> ... <persistence-unit name="LIMS"> <jta-data-source>jdbc/BeachWaterLIMS</jta-data-source> ... These persistence units correspond to JDBC resources and connection pools which I had defined in Glassfish as follows (include one here as both are identical apart from names & database connection info): JDBC Resource: JNDI Name: jdbc

Multiple jars, single persistence unit solution?

限于喜欢 提交于 2019-12-03 03:13:55
问题 Some people, including me, have been struggling with merging entities from different modules (jars) into a single persistence unit (especially with JavaSE , for instance here JPA 2.0: Adding entity classes to PersistenceUnit *from different jar* automatically ). Based on the answers there is no easy direct way to do that. One of solutions is to list all classes from all jars in single persistence unit file, but that's not really elegant. I might have accidentally found another way. Generally