persistence.xml

JPA2.1/ Hibernate 5.2 using Hibernate Tools to generate ddl via an ANT Maven task

≡放荡痞女 提交于 2019-12-14 02:01:39
问题 I have updated from Hibernate 4.3 to the latest version, currently 5.2.10.Final. I have the need for maven to generate the ddl schema so that when I run a drop database then create schema it will pick up the generated schmea which I am trying to get an ant task in maven to run. In my previous version I used... <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>2.2</version> I have followed the instructions found here so within my pom.xml I now have

Understanding Persistence.xml in JPA

时光怂恿深爱的人放手 提交于 2019-12-13 12:27:49
问题 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

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

别说谁变了你拦得住时间么 提交于 2019-12-12 08:23:43
问题 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 datasource in persistence.xml <persistence-unit name="kids-tomcat" transaction-type="JTA"> <jta-data-source>jdbc/kids</jta-data-source> </persistence-unit> I am getting following exception: org.hibernate.service.jndi.JndiException: Unable to lookup

JPA 2.1 testing: persisting the pre-loaded data

ⅰ亾dé卋堺 提交于 2019-12-12 04:43:46
问题 I'm testing my JPA classes using Arquillian against "remote" containers (Glassfish 4 and WildFly 10, to be specific). I want to: Generate the database schema from the JPA entities' definitions (as opposed to SQL scripts). Pre-load some data to imitate "the data that was already there". For a most trivial example, to test if I can remove an entity without creating it in the same test first. Be able to perform queries, inserts, updates, deletes, etc. There are javax.persistence.* properties

JPA - multiple persistence units

半腔热情 提交于 2019-12-12 02:53:15
问题 I'm using JPA and I am connecting to multiple databases. Below is the persistence.xml - <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="myRead" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="hibernate.show_sql" value="true" /> </properties> </persistence-unit> <persistence

EJB Project doesn't connect to the right Derby database/table

烂漫一生 提交于 2019-12-11 19:31:51
问题 having a problem yesterday that i couldn't connect to the derby database (most likely due to persistence.xml issues) I have been guided to modify my persistence.xml so that it contains two additional poperties; <property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> Having added them I don't get faced with bunch of errors such as SCHEMA "xx" doesn't exist or Unknown entity bean class: class model.Userbay,

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

别来无恙 提交于 2019-12-11 12:05:40
问题 I need that hibernate read a sql file before start junit tests, so I did the following configuration in persistence.xml: <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="test" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider>

Not able to read environment variable in persistence.xml

醉酒当歌 提交于 2019-12-11 11:59:22
问题 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 returns the correct path. But when I try to set the variable ${myDataDir} in my persistence.xml and then I start tomcat with "mvn tomcat:run" I get FileNotFoundExceptions because the variable is not replaced with the actual value (it says e.g. Cannot

JPA persistence.xml I want it to connect to MariaDB but it always connects to hsqldb

只愿长相守 提交于 2019-12-11 07:52:48
问题 I have a java webapp, persistence.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd" version="2.2"> <persistence-unit name="my-persistence-unit"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <exclude-unlisted-classes>false<

Change values in persistence.xml from within the program

旧时模样 提交于 2019-12-11 06:05:30
问题 Is it possible to change values in persistence.xml from within the program that is using it ? If yes, i would appreciate some hints or/and links to read. 回答1: Yes // connect to database log.info("Connecting to database @ " + dbUrl + " using " + dbUser + "/" + dbPass); emf = Persistence.createEntityManagerFactory("manager", Maps.create( "javax.persistence.jdbc.user", dbUser, "javax.persistence.jdbc.password", dbPass, "javax.persistence.jdbc.url", dbUrl )); 回答2: not part of jpa spec, so no.