Questions tagged [persistence.xml]

Used with the Java Persistence API, specifies names and database properties.

When used with the Java Persistence API, the persistence.xml file is usually placed in the META-INF folder; it's used to specify the persistence provider name, entity class names, and properties like the database connection URL, driver, user, password, and so on (taken from http://www.javaworld.com/javaworld/jw-01-2008/jw-01-jpa1.html?page=3).

519 questions
92
votes
6 answers

Create JPA EntityManager without persistence.xml configuration file

Is there a way to initialize the EntityManager without a persistence unit defined? Can you give all the required properties to create an entity manager? I need to create the EntityManager from the user's specified values at runtime. Updating the…
javydreamercsw
  • 5,363
  • 13
  • 61
  • 106
77
votes
1 answer

persistence.xml different transaction-type attributes

In the persistence.xml JPA configuration file, you can have a line like: or sometimes:
Germano Massullo
  • 2,572
  • 11
  • 40
  • 55
70
votes
11 answers

Why do I need to configure the SQL dialect of a data source?

When we configure a data source using Hibernate, we should add the hibernate.dialect property (or eclipselink.target-database if you are using EclipseLink). I want to know what is the meaning of dialect? I configure this property according to the…
Captain Kidd
  • 1,253
  • 2
  • 13
  • 20
60
votes
1 answer

How to specify JPA 2.1 in persistence.xml?

A quick search on the Net reveals three or four variants how folks have been specifying xmlns and xsi:schemaLocation in persistence.xml. What would be the 'correct' manner to specify JPA version 2.1? I'm using
kmansoor
  • 4,265
  • 9
  • 52
  • 95
40
votes
5 answers

Where to put persistence.xml in library jar using maven?

At work we have an entity library which is used by several clients for the library (several servlets, a desktop application, etc.). The entity library consists of JPA-Annotated classes and most prominently a persistence.xml. All projects are…
scravy
  • 11,904
  • 14
  • 72
  • 127
33
votes
2 answers

Multiple persistence-unit tags in one persistence.xml

I'm working now with a JPA 2.0 project (in Eclipse Indigo). In my persistence.xml file I need to specify two tags, because I have two different database to work with. Doing this, I get the following warning: Multiple persistence…
artaxerxe
  • 6,281
  • 21
  • 68
  • 106
24
votes
3 answers

Properties reference for hibernate in persistence.xml

Does anyone know a link, post, book or something else where are explained and nominalized all properties that you need and can use in persistence.xml file?
artaxerxe
  • 6,281
  • 21
  • 68
  • 106
19
votes
2 answers

Two Persistence Unit in one Persistence.xml

We created some libraries that all our projects will use, this libraries will provide the basic functionality of all our systems (login, some manage, etc). But the application itself could use another database. What we did was to create the…
zkropotkine
  • 337
  • 2
  • 5
  • 12
19
votes
4 answers

Changing Persistence Unit dynamically - JPA

Persistence units in persistence.xml are created during building the application. As I want to change the database url at runtime, is there any way to modify the persistence unit at runtime? I supposed to use different database other than pre-binded…
N K
  • 3,217
  • 5
  • 23
  • 38
17
votes
3 answers

How to use Hibernate SchemaUpdate class with a JPA persistence.xml?

I've a main method using SchemaUpdate to display at the console what tables to alter/create and it works fine in my Hibernate project: public static void main(String[] args) throws IOException { //first we prepare the configuration Properties…
John Rizzo
  • 771
  • 2
  • 10
  • 19
17
votes
1 answer

Eclipse - How to fix error "No persistence.xml file found in project" JPA issue

Error "No persistence.xml file found in project" in Eclipse. Aim: Create a new project GWT+App engine+Maven Steps to create this: Google eclipse plugin: select "New Web Application Project". set the name etc. right-click on the project >…
eddyparkinson
  • 3,680
  • 4
  • 26
  • 52
16
votes
6 answers

No Persistence provider for EntityManager named X

I am developing a JavaSE application using JPA. Unfortunately, I get null after calling: Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); Below you will find: A snippet of my code that invokes EntityManagerFactory and unexpectedly…
joshi737
  • 869
  • 3
  • 12
  • 26
15
votes
1 answer

Is there a way to scan JPA entities not to declare persistent classes in a persistence.xml file?

I would like to take advantage of JPA @Entity annotations not to declare class entities a J2SE persistence.xml file. What I'd like to avoid :
1tox
  • 327
  • 1
  • 4
  • 14
15
votes
4 answers

Eclipse: No generator named "system-uuid" is defined in the persistence unit

I have a maven enabled project imported into Eclipse. From Eclipse, I get an error "No generator named "system-uuid" is defined in the persistence unit" on the system-uuid portion of the following lines: @Id @GeneratedValue(generator =…
cmdematos
  • 883
  • 4
  • 12
  • 24
14
votes
4 answers

How to get Hibernate dialect during runtime

In my application, I use Hibernate with SQL Server database, so I set in my persistence.xml. In some case, I want to sort records with NULL include, I use keyword…
danisupr4
  • 815
  • 1
  • 9
  • 22
1
2 3
34 35