-->
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: hbm2java ignoring parts of reveng.xml?
PostPosted: Mon Nov 23, 2009 3:48 pm 
Beginner
Beginner

Joined: Tue Feb 03, 2009 4:33 pm
Posts: 21
I'm trying to map my table names to particular class names in reveng.xml, but hbm2Java appears to be ignoring these settings. Am I doing something wrong?
Code:
<hibernate-reverse-engineering>
    <table-filter match-name="SMS_Archive_.*" exclude="true"/>
    <table-filter match-name="SMS_.*" package="com.foo.sms.entities"/>
   
    <table name="SMS_Aggregator" class="Aggregator"/>
    <table name="SMS_Carrier" class="Carrier"/>
    <table name="SMS_Shortcode" class="Shortcode"/>
   
</hibernate-reverse-engineering>


When I generate my POJOs, they are coming out as SmsAggregator, SmsCarrier, etc., rather than the class names I designated in reveng.xml. Hbm2Java appears to be picking up all the other settings correctly (<table-filter>). What am I doing wrong here?


Top
 Profile  
 
 Post subject: Re: hbm2java ignoring parts of reveng.xml?
PostPosted: Mon Nov 23, 2009 3:54 pm 
Beginner
Beginner

Joined: Tue Feb 03, 2009 4:33 pm
Posts: 21
Figured it out. Apparantly, the catalog attribute of the table element is not optional when attempting to remap class names in this manner. I had tried using the "schema" attribute, but that didn't work. Apparantly for MySQL, you have to use "catalog" instead.

...but then again, I was never very clear on the difference between a "Schema" and a "Catalog".


Top
 Profile  
 
 Post subject: Re: hbm2java ignoring parts of reveng.xml?
PostPosted: Mon Nov 23, 2009 5:01 pm 
Beginner
Beginner

Joined: Tue Feb 03, 2009 4:33 pm
Posts: 21
Looks like I spoke too soon. The Class names being generated are now correct, but "foreign-key" properties that use these classes are being incorrectly named. (perhaps "incorrectly" is the wrong word).

For example, I got hbm2java to create the Aggregator class from the SMS_Aggregator table, but a field of type "Aggregator" in another class will still be called smsAggregator.

Any ideas?


Top
 Profile  
 
 Post subject: Re: hbm2java ignoring parts of reveng.xml?
PostPosted: Tue Dec 08, 2009 3:57 pm 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
roach wrote:
...but then again, I was never very clear on the difference between a "Schema" and a "Catalog".


This is one of the areas where there is not only no standard, but database vendors are handling things completely differently.

Most vendors use "schema" for a bunch of tables, and "catalog" for the area where the metadata on that table (such as name, column types, etc.) are stored.
However, "bunch of tables" may be all tables owned by a user, or all tables in something called a "database" (which can become a somewhat vague term in the presence of clustered databases).
Most vendors associate a schema with each user. I dimly remember that some database allowed a user to own multiple schemas, and the list of all schemas for that user would then be a "catalog" in the sense that Hibernate Tools uses the term, not in the usual "repository of metadata for a schema" sense.

It's all a real mess, and you're not alone in not being quite clear. The best thing you can do is to learn the terminology of your vendor, and how it applies to Hibernate Tools.

(What Hibernate Tools could do is to associate an explanation with the terms "catalog" and "schema" for each database dialect, and show the explanation in the GUI once a dialect has been chosen. It's one of the first hurdles any new Hibernate Tools user faces, and having to experiment with no clear feedback on whether it's correct now or not is a bit steep.)


Top
 Profile  
 
 Post subject: Re: hbm2java ignoring parts of reveng.xml?
PostPosted: Thu Dec 10, 2009 4:38 am 
Newbie

Joined: Thu Dec 10, 2009 3:33 am
Posts: 2
Hello:
i meet the same question, but when i do such modify, the question still hanppen. and my database is mysql too. below give my configuation, help me please, thanks much.
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-reverse-engineering
SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<schema-selection match-catalog="IREIS2" match-table="SB_.*" />

<type-mapping>
<sql-type jdbc-type="CHAR" hibernate-type="java.lang.String" />
<sql-type jdbc-type="BIGINT" length='20' hibernate-type="java.lang.Long" />
<sql-type jdbc-type="SMALLINT" hibernate-type="java.lang.Short" />
<sql-type jdbc-type="DECIMAL" hibernate-type="java.math.BigDecimal" />
<!--
<sql-type jdbc-type="DATETIME" hibernate-type="java.util.Date" />
-->
</type-mapping>
<table-filter match-name="AF_*" exclude="true"/>
<table
catalog="IREIS2"
name="SB_EQUIPMENT_FILE"
class="EquipmentFileDomain">
<primary-key>
<generator class="AUTO">
</generator>
<key-column name="EQUIPMENT_FILE_ID" property="keyword" />
</primary-key>
</table>

<table
catalog="IREIS2"
name="SB_CUSTOM_ANNEX"
class="CustomAnnex">
<primary-key>
<generator class="AUTO">
</generator>
<key-column name="ANNEX_ID" property="keyword" />
</primary-key>

<foreign-key constraint-name="FK_SB_C_ANNEX_SB_E_FILE"
foreign-table="SB_EQUIPMENT_FILE">
<column-ref local-column="EQUIPMENT_FILE_ID"
foreign-column="EQUIPMENT_FILE_ID" />
<many-to-one exclude="true" />
<set property="customAnneies" />
</foreign-key>
</table>
</hibernate-reverse-engineering>


Top
 Profile  
 
 Post subject: Re: hbm2java ignoring parts of reveng.xml?
PostPosted: Thu Dec 10, 2009 4:41 am 
Newbie

Joined: Thu Dec 10, 2009 3:33 am
Posts: 2
o, my question is "hbm2java ignoring parts of reveng.xml", as titile.


Top
 Profile  
 
 Post subject: Re: hbm2java ignoring parts of reveng.xml?
PostPosted: Sun Dec 13, 2009 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the rules are very simple:

Hibernate tools uses hibernate.default_schema and hibernate.default_catalog to know what the default schema and catalog are.

and

schema and catalog are the terms used by jdbc and what they mean depend on the specific jdbc driver implemenation you are using.

so if you have problems with matching tables then it is most likely because you haven't set hibernate.default_schema or hibernate.default_catalog
OR/and that the jdbc drivers implementation is doing something funky with them.

_________________
Max
Don't forget to rate


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.