-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: 2 persitence units in einem persitence.xml - File
PostPosted: Thu Jun 05, 2008 7:42 am 
Newbie

Joined: Thu Jun 05, 2008 7:02 am
Posts: 1
Hi,

Ich bin Hibernate-Neuling und habe folgendens Problem:
Ich möchte Teile einer DB-Tabelle von Oracle nach HSQL verarbeiten. Dazu benötige ich innerhalb meiner Anwendung 2 separate persistence units.

Hiezu verwende ich:
Hibernate Core 3.2.6
Hibernate Annotation 3.3.1
Hibernate EntityManager 3.3.2

Meine persistence.xml :
[/code]
<persistence 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/ ... ce_1_0.xsd" version="1.0">
<persistence-unit name="oracle">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/OracleDS</jta-data-source>
<class>test.Testdata</class>
<properties>
<property name="hibernate.archive.autodetection" value="xxx"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
</properties>
</persistence-unit>
<persistence-unit name="Hibernate">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/HibernateDS</jta-data-source>
<class>hello.Test</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.archive.autodetection" value="xxx"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
Code:

Zur Laufzeit bekomme ich dann folgende Fehlermeldung:

java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager test.TestdataHandlerBean.entityManager :EMPTY STRING unitName and there is more than one scoped persistence unit

Sobald ich z.B. die persistent unit für Oracle entferne, kann ich auf HSQL zugreifen und umgekehrt. Nur beides zusammen kann ich nicht zum Laufen bringen.

Währe super, wenn mir hier jemand weiter helfen könnte.

Danke

Tonreg.


Top
 Profile  
 
 Post subject: Re: 2 persitence units in einem persitence.xml - File
PostPosted: Thu Jun 12, 2008 2:52 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
tonreg wrote:
java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager test.TestdataHandlerBean.entityManager :EMPTY STRING unitName and there is more than one scoped persistence unit

Sobald ich z.B. die persistent unit für Oracle entferne, kann ich auf HSQL zugreifen und umgekehrt


Hi, du must beim EntityManager angeben, für welche persistent unit er arbeiten soll; z.B.:
Code:
@PersistenceContext(unitName="dpjw_office")
private EntityManager em;


Carlo
-------------------------------------
please credit me if this post helped you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.