-->
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.  [ 3 posts ] 
Author Message
 Post subject: use more than one persistence-unit in a par
PostPosted: Thu Mar 09, 2006 5:56 am 
Newbie

Joined: Thu Mar 09, 2006 5:48 am
Posts: 10
Hibernate version: 3.1
[Name and version of the database you are using:MySql

Hi All,
I want to use more than one persistence-unit in a par :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
  <persistence-unit name="DB1">
  <jta-data-source>java:/MySqlDS</jta-data-source>
  <properties>
     <property name="hibernate.hbm2ddl.auto"
              value="create-drop"/>
    <property name="hibernate.dialect"
              value="org.hibernate.dialect.MySQLDialect"/> 
  </properties>
  </persistence-unit>
<persistence-unit name="DB2">
  <jta-data-source>java:/MySqlDS2</jta-data-source>
  <properties>
     <property name="hibernate.hbm2ddl.auto"
              value="create-drop"/>
    <property name="hibernate.dialect"
              value="org.hibernate.dialect.MySQLDialect"/> 
  </properties>
  </persistence-unit> 
</persistence>


How can I tell hibernate for each entity class its belonging persistence-unit?
Code:
@Entity
class A {
}

when I deploy the code the table A is created in both data sources.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 12:24 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
What the problem of splitting to 2 pars?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 2:08 pm 
Newbie

Joined: Wed Dec 07, 2005 2:01 pm
Posts: 8
You can't. You have to create a par for each datasource you want to connect to. You can create pars with just a persistence.xml in them and have them reference the same group of beans.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.