Questions tagged [persistence-unit]

Persistence Unit is a logical grouping of user defined persistable classes (entity classes, embeddable classes and mapped superclasses) with related settings.

80 questions
22
votes
1 answer

Multiple jars, single persistence unit solution?

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*…
Adam Dyga
  • 8,666
  • 4
  • 27
  • 35
12
votes
3 answers

JPA Entity - Specify Persistence Unit?

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…
Shadowman
  • 11,150
  • 19
  • 100
  • 198
10
votes
1 answer

Is it possible to have two MSSQL persistence units in a transaction without XA?

We have an application that has a number of entity classes for which there must be two tables. The tables are identical, with the only difference being the name. The common solutions offered here on SO are to use inheritance (a mapped superclass and…
G_H
  • 11,739
  • 3
  • 38
  • 82
10
votes
2 answers

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

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…
Hanno Fietz
  • 30,799
  • 47
  • 148
  • 234
9
votes
2 answers

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

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:
8
votes
3 answers

How to bind an entity to a specific persistence-unit

In a web application using struts2 ejb hibernate, is it possible to tell the application to find or create an entity for a specific persistence-unit name, which is written in persistence.xml file, in the deployment time? I have two persistence-unit…
javatar
  • 4,542
  • 14
  • 50
  • 67
6
votes
5 answers

netbeans IDE: how to delete data source

I have a Java Web application that contains a Persistence unit. In this persistence unit I can select an existing data source or create a new data source. When I run this web application on the build in glassfish server, the data source is created…
WillamS
  • 2,457
  • 6
  • 24
  • 23
5
votes
1 answer

Multiple JPA persistence units pointing to same database?

Can we have more than one JPA persistence units pointing to same database, in different Java projects and deployed on the server at the same time? By same time I mean, not deployed at the same second but deployed together. I am using a hsqldb…
Vashishtha Jogi
  • 12,120
  • 2
  • 19
  • 20
5
votes
4 answers

@GeneratedValue doesn't work. "java.sql.SQLException: Field 'ID' doesn't have a default value"

Context: Jboss5.1, MySql 5.0 I've tried a lot of possibilities .. a simple @GeneratedValue or other solution specifing explicitly the sequence generator, but also have the same problem... There is the stack trace 22:00:53,334 INFO [STDOUT]…
vitokr
  • 87
  • 1
  • 1
  • 11
5
votes
1 answer

Hibernate SchemaExport and Persistence unit

A followup question to my previous question: Generate an SQL DB creation script with Hibernate 4 The goal is to have a command line tool able to generate a file with the SQL schema of a given persistence unit (similarly to the hibernatetool-hbm2ddl…
Matteo
  • 14,696
  • 9
  • 68
  • 106
4
votes
2 answers

WLS 10.3.4 - No persistence unit named 'xxx' is available in scope xxx_EJB.jar. Available persistence units: []

i have enterprise application project with 4 modules. it is deploy on WLS 10.3.4. i'm using eclipse helios for development with oracle web tools for eclipse. local WLS on my machine is installed as develpment mode. structure of project is like…
Kenny
  • 153
  • 1
  • 9
4
votes
2 answers

Hibernate 4 (Jboss as 7) can't auto detect entity and insert into PersistenceUnit, cause `unknown entity` exception

I meet a similar problem with this How to auto-register entities with JPA/Hibernate: Unknown entity . I am using jboss as 7, hibernate 4( which come along with jboss as 7), spring 3.0.5 . I annotate my entity class with @Entity. And using…
yzandrew
  • 785
  • 1
  • 11
  • 25
3
votes
1 answer

Is it possible to share configuration from persistence.xml?

I have one persistence unit configured in my persistence.xml but i have two databases. Those databases are identical, regarding the schema. What i am trying to do is: Persistence.createEntityManagerFactory("unit",…
whiskeysierra
  • 5,030
  • 1
  • 29
  • 40
3
votes
1 answer

spring jpa hibernate with more datasources

I have to use two different database in my application(spring) with Hibernate,Jpa. I'd like to define the different table directly to the different data sources. So I use two different persistence unit and I try to use
Shinigami
  • 1,015
  • 2
  • 15
  • 23
2
votes
3 answers

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

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…
Dan
  • 11,077
  • 20
  • 84
  • 119
1
2 3 4 5 6