-->
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.  [ 6 posts ] 
Author Message
 Post subject: Exclude catalog name from reverse-engineered Java classes
PostPosted: Sun Mar 09, 2008 8:19 am 
Newbie

Joined: Wed Feb 01, 2006 9:05 am
Posts: 4
I'm trying to reverse-engineer some classes from my 'dev' database, and then I want to be able to use those classes across my dev, test, and prod databases, since they're all generated from the same database definition.

However, the generated classes (from my hbm2java) all have the dev catalog listed in them. This causes my DAO's to target the dev database each time regardless of whether my dataSource is configured for test or prod.

I'm sure there must be a switch or property that will prevent inclusion of the catalog name in my generated classes, but all Googling has proved futile so far. Anybody know whether there's a switch I can use? Be much obliged.

Regards,
Darryl Pentz


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 11:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
when doing the reverse engineering set hibernate.default_catalog then hibernate tools won't put the catalog there if its the default.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 12:54 pm 
Newbie

Joined: Wed Feb 01, 2006 9:05 am
Posts: 4
Awesome! That did the trick. Thanks Max!


Top
 Profile  
 
 Post subject: Re: Exclude catalog name from reverse-engineered Java classes
PostPosted: Thu Aug 11, 2011 8:36 am 
Newbie

Joined: Thu Aug 11, 2011 8:20 am
Posts: 3
Hi I am a newbie in Hibernate. I am facing the same issue as mentioned by Darryl Pentz. I am using MyEclipse Enterprise Workbench 9 and sqlserver2008 as my DB. I am using Hibernate Reverse Engineering and use the feature " Hibernate annotation mapping to pojo " to generate pojo.

The pojo has annotations like

@Entity
@Table(name = "xxx", schema = "yyy", catalog = "zzz")

I have added <property name="hibernate.default_catalog">MyDatabaseName</property> in my hibernate.cfg.xml But, there is no change in the annotations in the generated pojo.

My requirement is that I should not get the catalog field in the generated pojo.

Please guide me


Last edited by ravishankar on Fri Aug 12, 2011 5:30 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Exclude catalog name from reverse-engineered Java classes
PostPosted: Thu Aug 11, 2011 10:55 am 
Newbie

Joined: Thu Aug 11, 2011 8:20 am
Posts: 3
Guys I figured it out on how to exclude the catalog field.

As stated before I added a property in my hibernate.cfg.xml as

<property name="hibernate.default_catalog">MyDatabaseName</property>

And also I added the hibernate.reveng.xml and used it to control the generation of pojo. I have pasted the hibernate.reveng.xml that I used

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
<table-filter match-schema=".*" match-name=".*"/>
</hibernate-reverse-engineering>

match-schema=".*" ------> it means select any / all the schema
match-name=".*" ------> it means select any / all the table from the schema


Top
 Profile  
 
 Post subject: Re: Exclude catalog name from reverse-engineered Java classes
PostPosted: Wed Sep 07, 2011 9:06 am 
Newbie

Joined: Wed Sep 07, 2011 8:56 am
Posts: 2
good that you shared this information)


http://coop-group.org/wakka.php?wiki=buycaviar


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