persistence.xml

JPA/Hibernate: create database schema and import data on first run, update schema on subsequent runs

谁都会走 提交于 2019-12-06 06:09:06
In my projects I often use JPA/Hibernate stack for database. When defining persistence.xml you have couple options you can set hibernate.hbm2ddl.auto . If set to create tables will be recreated on every application run (persisted data will be lost of course). It is also possible to import initial data by setting db fixture with hibernate.hbm2ddl.import_files . When set to update only tables for new entities will be created (persisted data in existing tables will be preserved). The thing is that this is not that convenient while developing and I'd like behavior like this: on first application

Hibernate JPA how to configure dynamic-update in persistence.xml

China☆狼群 提交于 2019-12-06 05:29:03
问题 I do NOT want to configure in my java source code which can be done like: @org.hibernate.annotations.Entity( dynamicUpdate = true) because I want it to be configurable. I am not using hibernate.properties, only persistence.xml as I am using JPA. How can I make dynamicUpdate as true for all entities using persistence.xml only? 回答1: You are using the JPA standard with the Hibernate implementation. In this case, you are attempting to configure something that is specific to the Hibernate

Multiple persistence units in Wildfly?

∥☆過路亽.° 提交于 2019-12-06 02:56:51
问题 Is it possible to have two persistence units in a Wildfly (9.0.2) application? I get "WFLYJPA0061: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "jasper-web.war". Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit." I have unitName specified in the @PeristenceContext annotations. I read somewhere I could disable <!--

persistence.xml not found in Eclipse Maven Project

点点圈 提交于 2019-12-06 02:10:34
问题 I cannot fix the persistence.xml file not found eclipse problem, this is a simple test project (Maven Nature) for a very basic EJB testing, the file is indeed in src/main/resources/META-INF/... this is the pom.xml contents. Tried adding the folder to the project's build path, updating maven project. No luck so far, any help would be greatly appreciated, thanks! <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/

Understanding Persistence.xml in JPA

若如初见. 提交于 2019-12-05 15:10:24
I am trying to understand the following things: When I make an EJB project and deploys it to Glassfish do I set up JDBC resources/connection pools at the administrator center of Glassfish or do I add all the different properites for username, password etc in the persistence.xml? I don't understand one bit of that. I do not understand why we have both JDBC resource and JDBC Connection pool either. What is it and what is the difference between them? Could somebody explain me these things or/and provide some good link about the persistence.xml file and the part around it? It's better to define a

C3P0: unreturnedConnectionTimeout in production?

这一生的挚爱 提交于 2019-12-05 11:27:23
The parameter unreturnedConnectionTimeout times out unreturned connections after a given period of time. I'm trying to decide whether I should use this in my production persistence.xml ? A big plus of using this is that the Connection Pool will be able to recover from leaky connections. A big minus is that leaky connections will be very difficult to detect. Should I use unreturnedConnectionTimeout in production applications? If yes, what should its value be? Are there any other pros/cons I should consider? Steve Waldman You should debug your Connection leaks, and then not use

Multiple persistence units in Wildfly?

半城伤御伤魂 提交于 2019-12-04 10:28:39
Is it possible to have two persistence units in a Wildfly (9.0.2) application? I get "WFLYJPA0061: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "jasper-web.war". Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit." I have unitName specified in the @PeristenceContext annotations. I read somewhere I could disable <!-- <subsystem xmlns="urn:jboss:domain:jpa:1.1"> <jpa default-datasource="" default-extended-persistence

persistence.xml for multiple persistence units

谁都会走 提交于 2019-12-04 09:19:38
问题 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 all described solutions that depend on additional frameworks. I'm trying to solve this using Glassfish 4.0 out-of-the-box, JPA 2.1 with EclipseLink 2.5 as the JPA provider. I'm using Eclipse, and realize that the IDE doesn't support configuring

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

末鹿安然 提交于 2019-12-04 08:21:08
问题 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 hibProps = new Properties(); hibProps.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("jbbconfigs.properties")); Configuration cfg = new AnnotationConfiguration(); cfg.configure("/hibernate.cfg.xml").addProperties(hibProps); //We

Can not create EntityManager factory bc JTA tx manager requiered

不问归期 提交于 2019-12-04 06:44:27
问题 I can not build my entity manager factory and the error I get is "chosen transaction strategy requires access to the JTA Transaction Manager". Can anyone advise what i have to configure to get past this? FYI I'm using Jboss 6, no spring. Here is my persistance.xml <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence