-->
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: Using several schemas
PostPosted: Thu Oct 07, 2004 9:23 am 
Newbie

Joined: Thu Oct 07, 2004 8:48 am
Posts: 3
Hibernate version: 2.16

Name and version of the database you are using:
DB2 UDB for AS/400. 05.02.0000 V5R2m0
AS/400 Toolbox for Java JDBC Driver v6.0


I am connecting to a DB2 database running on AS/400. We have an existing table structure and schema that is generated by Synon on the AS/400.

Synon is a 4th generation programming language to AS/400 developed by CA.

We connect to the database and must retrieve data's from different database schemas.

I can set the default database schema in the hibernate configuration file.
Code:
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">net.sf.hibernate.dialect.DB2400Dialect</prop>
                <prop key="hibernate.default_schema">xx</prop>
                <prop key="hibernate.show_sql">true</prop>
         </props>
      </property>


The example above will use xx as schema name for all my hibernate quries.

How do I change to use another schema name?

I would like to change the schema name "on-the-fly". Kinda like a parameter to my Hibernate finder code.

I checked the JavaDOC API and found two methods named setSchema but they are used during configuration and parsing of the mapping files.

Code:
setSchema(String) - Method in class net.sf.hibernate.mapping.Table
     
setSchemaName(String) - Method in class net.sf.hibernate.cfg.Mappings
    Sets the schemaName.



/Claus


Top
 Profile  
 
 Post subject: A solution from Spring
PostPosted: Fri Oct 08, 2004 9:13 am 
Newbie

Joined: Thu Oct 07, 2004 8:48 am
Posts: 3
A guy on the spring forum had the same problem:

http://forum.springframework.org/viewto ... =5007#5007

There is a pure SQL solution and a nice Springish elegant way of hiding it.


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.