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
14
votes
4 answers

JPA persistence.xml META-INF not working correctly

I am stumped when it comes to the location of my persistence.xml file. I am using eclipselink 2.4 as my JPA 2.0 implementation and have my persistence.xml located under src/main/resources/META-INF/persistence.xml as many posts state. The first…
Padawan
  • 770
  • 1
  • 8
  • 18
14
votes
2 answers

JNDI lookup works fine using lookUp but not when used in persistence.xml of JPA

I am using tomcat connection pool, jpa, hibernate. The datasource i created in context.xml of tomcat works fine if I try to get it using : source = (DataSource) ((Context) c.lookup("java:comp/env")).lookup("jdbc/kids"); but if i specify this jndi…
Deepak Singhal
  • 10,568
  • 11
  • 59
  • 98
13
votes
3 answers

persistence.xml with Glassfish 3.1.1

I am very new to glassfish, JPA and so on and I have really problems with setting that up. What I am planning to do is a simple RESTful service with a persistent backend. I am using glassfish3 as application server and already deployed a simple REST…
Eddy
  • 1,451
  • 2
  • 10
  • 10
13
votes
3 answers

How do I create a persistence.xml file for JPA and Hibernate?

I'm trying to use Hibernate JPA but I need to create my persistence.xml (so I can use the entity manager correctly). I am unsure of what to create and where to place it. This is how my hibernate.cfg.xml in 'Core' mode configured. I'm using Eclipse…
Valter Silva
  • 16,446
  • 52
  • 137
  • 218
13
votes
7 answers

Is it possible to have persistence.xml in a location other than META-INF?

I want to have my persistence.xml in conf folder of my app. How can I tell Persistence.createEntityManagerFactory that it should read it from there?
Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
12
votes
1 answer

Spring Cannot find class [org.hibernate.ejb.HibernatePersistence]

Im working on a java spring project on eclipse, and while Im trying to run the project through a JUnit test, I get and error : Cannot find class [org.hibernate.ejb.HibernatePersistence] . I looked for a lot of similar problems and no one could…
Aymane
  • 123
  • 1
  • 1
  • 5
12
votes
3 answers

persistence.xml to import database parameters values from .properties file

Edit: not duplicate but almost I would like to have my app persistence.xml to be something like
paulochf
  • 690
  • 2
  • 11
  • 21
11
votes
3 answers

Persistence.xml where to put in eclipse project

Simple question... I have a few projects in Eclipse enviroment MainApp(Enterprise Application Project) which "includes" WebController (EJB Project) WebModel (JPA Project) WebView(Dynamic Web Project) Problem is where to put persistance.xml…
Marcin Petrów
  • 1,447
  • 5
  • 24
  • 39
11
votes
1 answer

JPA / EclipseLink - create script source with one SQL statement taking multiple lines

I want to let the persistence provider (EclipseLink 2.5.0) automatically create the tables in the, already existing, database by using the persistence unit property "javax.persistence.schema-generation.create-script-source" and a valid…
Marc Beckers
  • 143
  • 1
  • 9
11
votes
1 answer

persistence.xml for multiple persistence units

I'm trying to persist the same entity to both MySQL and Postgres databases (this is primarily to identify any inconsistencies, and work out the details of any issues doing the dual-write -- which I've run into here). The articles I've found have…
CraftWeaver
  • 707
  • 1
  • 8
  • 21
10
votes
2 answers

EclipseLink JPA - location of persistence.xml

I am using JPA for a java class and having trouble putting the persistence XML file where it should be. The IDE i am using is Eclipse Helios. Eclipselink jar files are downloaded and added to my JRE System Library and all. I wrote up the…
neid
  • 315
  • 1
  • 4
  • 12
10
votes
3 answers

Problems with generating sql via eclipseLink - missing separator

i'am using eclipseLink with jpa. in my persistence.xml, i defined to generate a create.sql file. the file will be generated, but with missing ';'-separators for each sql statement. is there a possibility to define a separator in the persistence.xml…
0xPixelfrost
  • 10,244
  • 5
  • 39
  • 58
9
votes
1 answer

Ljava.lang.String class cannot be resolved in persistence.xml

I am using JBoss Developer Studio. I have a project with a persistence.xml file. The file is perfect to me, but I keep getting this error on the tab that lists all the Problems of my project. Class "[Ljava.lang.String;@22ec7158" cannot be…
Jadiel de Armas
  • 8,405
  • 7
  • 46
  • 62
9
votes
1 answer

JPA 2.0, hibernate 3.5, jars & persistence.xml location

I'm building a desktop application using hibernate 3.5 & JPA 2.0. I have 2 jars, the lib, which defines every entity and DAO, packages looks like this : org.my.package.models org.my.package.models.dao org.my.package.models.utils In…
amirouche
  • 7,682
  • 6
  • 40
  • 94
9
votes
3 answers

why EntityManager is null?

In my web applicaton I use OpenJPA on Apache Tomcat (TomEE)/7.0.37 server. I use Netbeans to auto generate class ("Entity Class from database..." and "Session Beans From Entity Class..."). At SessionBean (for example UserFacade) i want to get…
kuba44
  • 1,838
  • 9
  • 34
  • 62
1
2
3
34 35