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
1
vote
0 answers

Why am I forced to list entity classes in persistence.xml?

TomEE 1.6 JPA 2.0 Hibernate 2.4.8 MySQL. exclude-unlisted-classes set to false should not force me to list entities. Without com.acme.Person, I get 'Unknown entity com.acme.Person'. Anyone knows why?
jacekn
  • 1,521
  • 5
  • 29
  • 50
1
vote
2 answers

JDOPersistenceManager memory leak

Using JDO JDOPersistenceManager, I keep getting memory leak detection reports from Plumbr, what is the correct way to create and destroy a JDOPersistenceManager Plumbr report: The objects are created at…
bsautner
  • 4,479
  • 1
  • 36
  • 50
1
vote
1 answer

JPA Entity is unknown

I'm tring to insert my student object to Students table in mydb database, but always get exception. However connecting to table using Connection works properly. I'm using Eclipse with EclipseLink. entity class package student; import…
1
vote
3 answers

hibernate.hbm2ddl.import_files in persistence.xml is not working

I need that hibernate read a sql file before start junit tests, so I did the following configuration in persistence.xml:
Leo
  • 93
  • 1
  • 2
  • 9
1
vote
2 answers

Exclude one class from creating a Table in hibernate

I have a persistence unit like this: org.hibernate.ejb.HibernatePersistence com.example.User
user1224036
  • 988
  • 1
  • 15
  • 34
1
vote
1 answer

Error: No Persistence provider for EntityManager

There are so many questions about this error message already on StackOverflow, but I can't find a solution... The error is: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.persistence.PersistenceException: No Persistence…
AllieCat
  • 3,890
  • 10
  • 31
  • 45
1
vote
1 answer

Not able to read environment variable in persistence.xml

I have a Maven3 project where I'm using the tomcat7-maven-plugin. I would like to set the path for the embedded database via an environment variable argument to the jvm. Reading the variable with System.getenv("myDataDir") within a Java-Method…
1
vote
0 answers

persistence.xml configuration to fetch a property value from property file dynamically

I have persistence.xml in my project. In this I have use different property tags for Data Base User Name and Password for same. I want value of this property to be set at run time while loading. Instead of having such code,
1
vote
1 answer

eclipselink without persistence.xml and multiple persistence.xml

Hi I am trying to develop a JPA application using EclipseLink. I am trying to create it without persistence.xml or at least the Persistence Unit will be created during run time. So I have an empty (or rather dummy) persistence.xml to start with. I…
PGK
  • 141
  • 3
  • 12
1
vote
0 answers

When is persistence.xml necessary for Play 2.1.1 Java? Entities don't persist in a many-to-one relationship

In my program, I have a Task model with a allDates field, which is a collection of all the Dates that task occurs on. My goal is to make a calendar manager that allows users to input tasks that repeat on certain days. In Tasks, I defined a OneToMany…
Emily Chen
  • 247
  • 1
  • 3
  • 8
1
vote
1 answer

Duplicate ClassLoaders generated per persistence-unit on Websphere

We're running an EAR on WAS 8.5, and every one of our DAOs are duplicated 31 times. Noticing our persistence.xml has 30 JNDI datasources, I tested reducing the number, and indeed the duplicate count decreases. But I've tried removing every…
djb
  • 1,635
  • 3
  • 26
  • 49
1
vote
2 answers

InvocationTargetException: javax/persistence/Persistence

Im trying to follow the example in chapter 2 of the book Beginning Java EE 6 Platform with GlassFish 3. I am using EclipseLink, Derby and Maven from cmd in Windows. I really can't figure this out and would be grateful for some help! This line…
user1766169
  • 1,932
  • 3
  • 22
  • 44
1
vote
2 answers

Difference between EntityManagerFactory and SessionFactory?

I am new to Hibernate and JPA .Right now I am using EntityManagerFactory Instance to create EntityManager then I have UnWrap this EntityManager into Session using entityManager = entityManagerFactory.createEntityManager(); session =…
user1679378
  • 1,370
  • 3
  • 17
  • 23
1
vote
1 answer

JPA create-or-extend tables

DDL generation "create-or-extend-tables" works with EclipseLink2.4. An extra column is created when i do JPA Tools-> Generate tables from entity. But why doesn't this alteration of table not happen automatically during deployment of application?…
balajiboss
  • 932
  • 2
  • 12
  • 20
1
vote
4 answers

java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass

I am new to JPA & hibernate, when I try this tutorial . I added the following provider in my persistence.xml, org.hibernate.ejb.HibernatePersistence and I am getting this error.. log4j:WARN No appenders could be found for…