persistence.xml

Configure persistence units to be available in several jars of an ear

蹲街弑〆低调 提交于 2019-12-04 01:56:23
问题 In a .ear file, my EJBs are copied in several jar and war for some technical constraints. And only one of these jar contains the persistence.xml file where I have configured several persistence units. myear.ear |---- myjar1.jar |-------- META-INF/persistence.xml |---- myjar2.jar |---- mywar.war The problem is Jboss cannot find the persistence configuration for the classes within the jar "myjar2" and the war : Could not get class configuration for ....EjbA.class due to the following errors:

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

大城市里の小女人 提交于 2019-12-04 01:14:19
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 JNDI name [jdbc/kids] Any idea why it could happen ! Finally it worked today after i specified the

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

余生长醉 提交于 2019-12-03 17:23:08
问题 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 SQL-DDL-script. persistence.xml: <property name="javax.persistence.schema-generation.create-script-source" value="data/ddl.sql"/> ddl.sql: USE myDatabase; CREATE TABLE MyTable ( id INTEGER NOT NULL AUTO_INCREMENT, myColumn VARCHAR(255) NOT NULL, PRIMARY KEY (id

EclipseLink JPA - location of persistence.xml

不打扰是莪最后的温柔 提交于 2019-12-03 13:13:43
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.PersistenceProvider</provider> The program still doesn't run so i am wondering where should I place persistence.xml (i.e

Two Persistence Unit in one Persistence.xml

大憨熊 提交于 2019-12-03 09:04:42
问题 We created some libraries that all our projects will use, this libraries will provide the basic functionality of all our systems (login, some manage, etc). But the application itself could use another database. What we did was to create the Persistence.xml with two persist units. And package all the core library entities in a jar called "LN-model.jar" and all of the entities of out test app in "App-model.jar". But for some reason we still obtain the following message. Could not resolve a

Properties reference for hibernate in persistence.xml

时光毁灭记忆、已成空白 提交于 2019-12-03 08:43:21
问题 Does anyone know a link, post, book or something else where are explained and nominalized all properties that you need and can use in persistence.xml file? 回答1: The JPA 2.0 supported properties ( javax.persistence.* ) can be found in JPA 2.0 specification. Vendor-specific properties can be found in appropriate vendor documentation: Hibernate properties (hibernate.*) EclipseLink properties (eclipselink.*) 回答2: Full list of properties, that hibernate uses, you can find in class org\hibernate

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

半世苍凉 提交于 2019-12-03 06:17:19
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 SQL-DDL-script. persistence.xml: <property name="javax.persistence.schema-generation.create-script-source" value="data/ddl.sql"/> ddl.sql: USE myDatabase; CREATE TABLE MyTable ( id INTEGER NOT NULL AUTO_INCREMENT, myColumn VARCHAR(255) NOT NULL, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE = utf8_bin; But I got the following

persistence.xml for multiple persistence units

你。 提交于 2019-12-03 03:27:33
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 multiple persistence units in the persistence.xml file, so I'm writing the XML for that directly. I was

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

时光毁灭记忆、已成空白 提交于 2019-12-02 22:41:42
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 create the SchemaUpdate thanks to the configs SchemaUpdate schemaUpdate = new SchemaUpdate(cfg); //The

Properties reference for hibernate in persistence.xml

淺唱寂寞╮ 提交于 2019-12-02 22:36:29
Does anyone know a link, post, book or something else where are explained and nominalized all properties that you need and can use in persistence.xml file? Piotr Nowicki The JPA 2.0 supported properties ( javax.persistence.* ) can be found in JPA 2.0 specification . Vendor-specific properties can be found in appropriate vendor documentation: Hibernate properties ( hibernate.* ) EclipseLink properties ( eclipselink.* ) Ilya Full list of properties, that hibernate uses, you can find in class org\hibernate\cfg\Environment.java in Hibernate distribution. Javadoc here I think there are actually 2