-->
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.  [ 7 posts ] 
Author Message
 Post subject: default_schema setting affects generated class name?
PostPosted: Wed Jan 09, 2008 6:52 pm 
Newbie

Joined: Wed Jan 19, 2005 2:39 pm
Posts: 16
Hibernate version:3.2.0.cr4
Hibernate Tools version:3.2.0.GA
Database: Oracle 10

We're reverse engineering pojos and the hibernate.cfg.xml file. We also have separate database 'regions'. i.e. we'll have a CLIENT_DEV schema and CLIENT_PROD schema.

For that reason, we specifically don't set hibernate.default_schema - that way we can use the same persistence layer throughout the regions.

However, without hibernate.default_schema set, this type of class definition for the table in the reveng.xml file seems to have no effect:

Code:
   

<table name="USR" class="com.mycompany.myproj.persistence.User">
   <primary-key>
      <generator class="sequence" >
         <param name="sequence">USR_SEQ</param>
      </generator>
   </primary-key>
</table>



What I mean is the tools generate a Usr.java file instead of the desired User.java file. Again, setting default_schema allows the code generation to happen as expected.

Any assistance in clearing up my confusion would be appreciated.

Thanks
M


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 5:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes it has no effect because the table name is now not unique, it would need a schema name.

You can just set hibernate.default_schema only when you do the reverse engineering it does not need to be set when running hibernate runtime.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 4:58 pm 
Newbie

Joined: Wed Jan 19, 2005 2:39 pm
Posts: 16
Thanks Max - That makes perfect sense...

But now I don't see any way to generate the hibernate.cfg.xml file with the proper class name:

Code:
<mapping class="com.mycompany.myproj.persistence.User" />


(instead of Usr)

Without also generating:

Code:
<property name="hibernate.default_schema">CLIENT_DEV</property>


Which makes my persistence layer schema specific.

Am I missing something - or just asking too much :)
Thanks again.
M


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 5:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
chicken and egg ,)

well you could generate the hbm.xml's first with the schema set and then do a second run to generate the cfg.xml by including the *.hbm.xml's by **/*.hbm.xml

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 7:18 pm 
Newbie

Joined: Wed Jan 19, 2005 2:39 pm
Posts: 16
Thanks again -

But I'm not quite tracking with you - how do you create a cfg.xml from the hbm.xml set?

M


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 11, 2008 3:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
from the docs 4.3.1.1:

Code:
<hibernatetool destdir="${build.dir}/generated">
<configuration propertyfile="{etc.dir}/hibernate.properties">
   <fileset dir="${src.dir}">
   <include name="**/*.hbm.xml"/>
  </fileset>
</configuration>

<hbm2cfgxml/>

</hibernatetool>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 11, 2008 11:26 am 
Newbie

Joined: Wed Jan 19, 2005 2:39 pm
Posts: 16
Thanks! Shoulda spotted that in the docs. Worked like a charm!

M


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