-->
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: Annotations and scheme for different databases
PostPosted: Tue May 15, 2007 4:56 am 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
Hi all, has anyone dealt with Annotations and different databases for objects (I am using 2 different Sybase databases located on the same server)?

There is no scheme attribute for the @Entity, what should I use then for specifying different database? Tried searching the forum but no luck. Thanks.

Hibernate version:
3.2.2
Mapping documents:
@Entity (name="dbone..profile")
public class Profile implements Serializable {

Name and version of the database you are using:
Sybase ASE 12.5.4


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 7:32 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

Just a quick question, what environment are you running hibernate in ? Seems as you have mentioned the @Entity annotation, i am assuming that you are using it in an EJB3/App Server environment (correct me if i am wrong).

The way i would try do it (it might not work) is to define 2 seperate datasources. Then in the persistence.xml I would declare 2 persistence units like so:

Code:
<persistence>
   <persistence-unit name="DB1">
      <jta-data-source>java:/<datasource 1></jta-data-source>
      ............................................
   </persistence-unit>
   <persistence-unit name="DB2">
      <jta-data-source>java:/<datasource 2></jta-data-source>
       ............................................
   </persistence-unit>
</persistence>


The you could declare 2 EnityManagers each with a different persistence context.

You also mention that there is no schema attribute for @Entity, which is true. You have to use the @Table attribute like so:

Code:
@Entity
@Table(name = "<table_name>", schema="<schema_name>")


Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject: Thanks all, sorted out the issue with @Table attribute
PostPosted: Tue May 15, 2007 7:56 am 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
Thanks all, sorted out the issue with @Table (schema="mydb") attribute


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.