persistence.xml

Modify persistence.xml on runtime

落花浮王杯 提交于 2020-06-27 14:57:17
问题 I'm developping a program that uses JPA, and I deployed it in a single jar. I wish to modify (or ask to the user, in an menú item) the configuration of the connection data with the database server. It's possible to modify the data (user, password, ip) of the server "on the fly"? (I apologize my bad english) 回答1: The JPA spec doesn't allow for dynamic modification of persistence-units. Some implementations may provide an implementation-specific way of defining a persistence-unit dynamically.

Modify persistence.xml on runtime

◇◆丶佛笑我妖孽 提交于 2020-06-27 14:56:28
问题 I'm developping a program that uses JPA, and I deployed it in a single jar. I wish to modify (or ask to the user, in an menú item) the configuration of the connection data with the database server. It's possible to modify the data (user, password, ip) of the server "on the fly"? (I apologize my bad english) 回答1: The JPA spec doesn't allow for dynamic modification of persistence-units. Some implementations may provide an implementation-specific way of defining a persistence-unit dynamically.

persistence-unit, different hibernate.transaction.manager_lookup_class property

五迷三道 提交于 2020-03-03 06:05:46
问题 I have Java EE application, and my EJB module have persistence.xml . I deploy my app on 3 app servers: JBoss, GlassFish and WebLogic, and every server needs own hibernate.transaction.manager_lookup_class property. WL needs <property name="transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup" /> JBoss needs <property name="transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" /> Glass fish <property name

EclipseLink JPA - location of persistence.xml

不羁岁月 提交于 2020-02-26 12:38:26
问题 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 persistence.xml with the tag after getting the following error : Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named customers Provider tag: <provider>org.eclipse.persistence.jpa

How to get Hibernate dialect during runtime

丶灬走出姿态 提交于 2020-01-24 02:29:06
问题 In my application, I use Hibernate with SQL Server database, so I set <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"> in my persistence.xml. In some case, I want to sort records with NULL include, I use keyword NULLS FIRST. Because it is not supported by default by CriteriaQuery/CriteriaBuilder in Hibernate, then I use Interceptor to modify the native query. The problem is, keyword NULLS FIRST is not supported in SQL Server, so I use keyword: case when

OpenJPA 2.1.1 - Cannot find the declaration of element 'persistence'

若如初见. 提交于 2020-01-14 10:32:39
问题 I just downloaded http://www.apache.org/dyn/closer.cgi/openejb/4.0.0-beta-1/apache-tomee-1.0.0-beta-1-webprofile.zip to use OpenEJB with OpenJPA2.1.1. I can't get my persistence.xml working. The top of the stack trace: org.xml.sax.SAXException: file:/D:/Workspaces/sandbox/tomcat_ejb_jpa2_tomEE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/testEE/WEB-INF/classes/META-INF/persistence.xml [Location: Line: 2, C: 248]: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the

How can I make a JPA application access different databases?

拟墨画扇 提交于 2020-01-09 05:33:10
问题 I'm writing a Java SE (desktop) application that has to access different databases all of which will have the same data model (same schema, tables, etc.). I want to reuse the JPA Entities that I already use in a Java EE application that front each database. To reuse the existing entity.jar file I'll have to repackage it with a different persistence.xml that has a resource_local data source. That's an build time inconvenience but not a big problem. The problem is that my desktop application

Spring Persistence archive and entitymanager is null when accessing from web-application

孤街醉人 提交于 2020-01-05 04:41:06
问题 I've created a jar file through spring roo (maven project - persistence archive) unit tests are running fine, the concerned files are on the following location jarFile/META-INF/persistence.xml jarFile/META-INF/applicationContext.xml jarFile/META-INF/applicationContext-jpa.xml jarFile/META-INF/database.properties Unit tests are running fine. Because its a maven project I added it to local repository by executing the command "mvn install" and after that I added it as a dependency to another

Cannot call JNDI resource in persistence.xml file

空扰寡人 提交于 2020-01-04 11:44:28
问题 Although it seems many users faced the same problem, I have to post my own issue, taking in account that for now, no suggestion from those already present worked for me. Or maybe am I missing something? Here is my persistence.xml file (located uner resources/META-INF/ directory, in a maven project): <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 04:00:09
问题 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 > Configure > Convert to Maven... Fix jdoconfig.xml file: xsi has the wrong value. see Validating jdoconfig with incorrect url Then I get the above error. The file exists at scr/META-INF/persistence.xml and also war/WEB-INF/classes/META-INF/persistence.xml But