-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate/Middlegen generates multiple columns
PostPosted: Mon Nov 24, 2003 6:40 am 
Newbie

Joined: Mon Nov 24, 2003 6:22 am
Posts: 2
Location: Norway
I am using Hibernate 2.0.3 and middlegen-2.0-b2-dev.jar and middlegen-hibernate-plugin-2.0b2-dev.jar. Using a ant task as shown below, I want middlegen to create the hbm.xml-files from my existing database.

The problem is that some of the tables get multiple instances of its columns. I could correct this manually afterwards by editing the *.hbm.xml-files, but this is not a good solution.

I have searched the forums without finding any posts about this, so I would really appreciate some hints.

build.xml excerpt: (sorry about the large post)
===========

<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
depends="cleanDescriptors, prepareDescriptors">

<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="classpath.run"
/>

<middlegen
appname="${appname}"
prefsdir="${descDir}"
gui="${gui}"
databaseurl="${database.url}"
driver="${database.driver}"
username="${database.username}"
password="${database.password}"
>

<table name="ADSE_SESSION" singular="ADSE_SESSION"
plural="ADSE_SESSION"/>
<table name="ADSM_SESSIONMODIFIED" singular="ADSM_SESSIONMODIFIED"
plural="ADSM_SESSIONMODIFIED">
<crossref fktable="ADSE_SESSION" fkcolumn="ADSE_GUID"/>
</table>
<table name="ADLO_LOG" singular="ADLO_LOG" plural="ADLO_LOG">
<crossref fktable="ADJO_JOB" fkcolumn="ADJO_GUID"/>
</table>
<table name="ADFL_FLAGS" singular="ADFL_FLAGS"
plural="ADFL_FLAGS">
<crossref fktable="ADCH_CHANNEL" fkcolumn="ADCH_GUID"/>
</table>
<table name="ADCH_CHANNEL" singular="ADCH_CHANNEL"
plural="ADCH_CHANNEL">
<crossref fktable="AQTS_TIMESERIES" fkcolumn="AQTS_GUID"/>
</table>
<table name="ADIN_INSTRUMENT" singular="ADIN_INSTRUMENT"
plural="ADIN_INSTRUMENT">
<crossref fktable="AQST_STATION" fkcolumn="AQST_GUID"/>
</table>
<table name="AQTE_TIMEVALUE" singular="AQTE_TIMEVALUE"
plural="AQTE_TIMEVALUE">
<crossref fktable="AQTS_TIMESERIES" fkcolumn="AQTS_GUID"
pkcolumn="AQTE_GUID"/>
<crossref fktable="AQQA_QAFLAG" fkcolumn="AQQA_GUID"
pkcolumn="AQTE_GUID"/>
<crossref fktable="AQQC_QUALITYCONTROLLEVELFLAG"
fkcolumn="AQQC_GUID" pkcolumn="AQTE_GUID"/>
</table>
<table name="AQTS_TIMESERIES" singular="AQTS_TIMESERIES"
plural="AQTS_TIMESERIES">
<crossref fktable="AQST_STATION" fkcolumn="AQST_GUID"
pkcolumn="AQTS_GUID"/>
<crossref fktable="AQUN_UNIT" fkcolumn="AQUN_GUID"
pkcolumn="AQTS_GUID"/>
</table>
<table name="AQRW_RAWDATAVALUES" singular="AQRW_RAWDATAVALUES"
plural="AQRW_RAWDATAVALUES">
<crossref fktable="AQTS_TIMESERIES" fkcolumn="AQTS_GUID"/>
</table>
<table name="AQQV_QAFLAGVALUE" singular="AQQV_QAFLAGVALUE"
plural="AQQV_QAFLAGVALUE">
<crossref fktable="AQQA_QAFLAG" fkcolumn="AQQA_GUID"
pkcolumn="AQQV_GUID"/>
<crossref fktable="AQTS_TIMESERIES" fkcolumn="AQTS_GUID"
pkcolumn="AQQV_GUID"/>
</table>

<table name="ADJO_JOB" singular="ADJO_JOB" plural="ADJO_JOB"/>
<table name="ADJT_JOBTYPE" singular="ADJT_JOBTYPE"
plural="ADJT_JOBTYPE"/>
<table name="AQQC_QUALITYCONTROLLEVELFLAG"
singular="AQQC_QUALITYCONTROLLEVELFLAG"
plural="AQQC_QUALITYCONTROLLEVELFLAG"/>
<table name="AQUN_UNIT" singular="AQUN_UNIT" plural="AQUN_UNIT"/>
<table name="AQST_STATION" singular="AQST_STATION"
plural="AQST_STATION"/>
<table name="AQQA_QAFLAG" singular="AQQA_QAFLAG"
plural="AQQA_QAFLAG"/>
<table name="ADLD_LOGDATA" singular="ADLD_LOGDATA"
plural="ADLD_LOGDATA"/>

<!--<table name="ADREL_ADCH_ADIN" plural="ADREL_ADCH_ADIN"/>-->
<!--<table name="ADREL_ADJO_ADSE" plural="ADREL_ADJO_ADSE"/>-->

<!-- Plugins -->
<hibernate
destination="${descDir}"
package="${pojoPackage}"
genXDocletTags="true"
genIntergratedCompositeKeys="true"
/>

</middlegen>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 8:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Thanks for the report but I dont have enough information.
What version of the plugin are you using? r3?
Can you please show a small example schema and the resulting hbm file please.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 5:40 am 
Newbie

Joined: Mon Nov 24, 2003 6:22 am
Posts: 2
Location: Norway
The plugin I'm using is r3.

A given table can have these columns:

CREATE TABLE GRENLAND_AUTOMATIC.AQTE_TIMEVALUE
(
AQTE_GUID CHAR(38) NOT NULL,
TE_TOTIME DATE NOT NULL,
TE_VALUE NUMBER NULL,
AQTS_GUID CHAR(38) NULL,
AQQA_GUID CHAR(38) NULL,
AQQC_GUID CHAR(38) NULL,
TE_FROMTIME DATE NOT NULL,
TE_CHANGEDDATE DATE NULL,
TE_CHANGEDBY CHAR(38) NULL,
CONSTRAINT SYS_C007601
FOREIGN KEY (AQQC_GUID)
REFERENCES GRENLAND_AUTOMATIC.AQQC_QUALITYCONTROLLEVELFLAG (AQQC_GUID),
CONSTRAINT SYS_C007602
FOREIGN KEY (AQQA_GUID)
REFERENCES GRENLAND_AUTOMATIC.AQQA_QAFLAG (AQQA_GUID),
CONSTRAINT SYS_C007603
FOREIGN KEY (AQTS_GUID)
REFERENCES GRENLAND_AUTOMATIC.AQTS_TIMESERIES (AQTS_GUID)
)

Using middlegen as described in my previous post, I get the following result: (Again, sorry about the long post)

<?xaml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="com.nilu.adacs.hibernate.AQTE_TIMEVALUE"
table="AQTE_TIMEVALUE"
>
<meta attribute="field-description">
@hibernate.class
table="AQTE_TIMEVALUE"
</meta>

<composite-id>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="aqteGuid"
column="AQTE_GUID"
type="java.lang.String"
length="38"
/>
<key-property
name="aqteGuid"
column="AQTE_GUID"
type="java.lang.String"
length="38"
/>
<key-property
name="aqteGuid"
column="AQTE_GUID"
type="java.lang.String"
length="38"
/>
</composite-id>

<property
name="teTotime"
type="java.sql.Timestamp"
column="TE_TOTIME"
not-null="true"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_TOTIME"
length="7"
not-null="true"
</meta>
</property>
<property
name="teValue"
type="java.math.BigDecimal"
column="TE_VALUE"
length="22"
>
<meta attribute="field-description">
@hibernate.property
column="TE_VALUE"
length="22"
</meta>
</property>
<property
name="aqtsGuid"
type="java.lang.String"
column="AQTS_GUID"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="AQTS_GUID"
length="38"
</meta>
</property>
<property
name="aqqaGuid"
type="java.lang.String"
column="AQQA_GUID"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="AQQA_GUID"
length="38"
</meta>
</property>
<property
name="aqqcGuid"
type="java.lang.String"
column="AQQC_GUID"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="AQQC_GUID"
length="38"
</meta>
</property>
<property
name="teFromtime"
type="java.sql.Timestamp"
column="TE_FROMTIME"
not-null="true"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_FROMTIME"
length="7"
not-null="true"
</meta>
</property>
<property
name="teChangeddate"
type="java.sql.Timestamp"
column="TE_CHANGEDDATE"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_CHANGEDDATE"
length="7"
</meta>
</property>
<property
name="teChangedby"
type="java.lang.String"
column="TE_CHANGEDBY"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="TE_CHANGEDBY"
length="38"
</meta>
</property>
<property
name="teTotime"
type="java.sql.Timestamp"
column="TE_TOTIME"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_TOTIME"
length="7"
</meta>
</property>
<property
name="teValue"
type="java.math.BigDecimal"
column="TE_VALUE"
length="22"
>
<meta attribute="field-description">
@hibernate.property
column="TE_VALUE"
length="22"
</meta>
</property>
<property
name="aqtsGuid"
type="java.lang.String"
column="AQTS_GUID"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="AQTS_GUID"
length="38"
</meta>
</property>
<property
name="aqqaGuid"
type="java.lang.String"
column="AQQA_GUID"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="AQQA_GUID"
length="38"
</meta>
</property>
<property
name="aqqcGuid"
type="java.lang.String"
column="AQQC_GUID"
length="38"
>
<meta attribute="field-description">
@hibernate.property
column="AQQC_GUID"
length="38"
</meta>
</property>
<property
name="teFromtime"
type="java.sql.Timestamp"
column="TE_FROMTIME"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_FROMTIME"
length="7"
</meta>
</property>
<property
name="teTotime"
type="java.sql.Timestamp"
column="TE_TOTIME"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_TOTIME"
length="7"
</meta>
</property>
<property
name="teValue"
type="java.math.BigDecimal"
column="TE_VALUE"
length="22"
>
<meta attribute="field-description">
@hibernate.property
column="TE_VALUE"
length="22"
</meta>
</property>
<property
name="teFromtime"
type="java.sql.Timestamp"
column="TE_FROMTIME"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TE_FROMTIME"
length="7"
</meta>
</property>

<!-- associations -->
<!-- bi-directional many-to-one association to AQTS_TIMESERIES -->
<many-to-one
name="AQTS_TIMESERIES"
class="com.nilu.adacs.hibernate.AQTS_TIMESERIES"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="AQTS_GUID"
</meta>
<column name="AQTS_GUID" />
</many-to-one>
<!-- bi-directional one-to-many association to AQTS_TIMESERIES -->
<set
name="AQTS_TIMESERIES"
lazy="true"
inverse="true"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"

@hibernate.collection-key
column="AQTS_GUID"

@hibernate.collection-one-to-many
class="com.nilu.adacs.hibernate.AQTS_TIMESERIES"
</meta>
<key>
<column name="AQTS_GUID" />
</key>
<one-to-many
class="com.nilu.adacs.hibernate.AQTS_TIMESERIES"
/>
</set>
<!-- bi-directional one-to-many association to AQQC_QUALITYCONTROLLEVELFLAG -->
<set
name="AQQC_QUALITYCONTROLLEVELFLAG"
lazy="true"
inverse="true"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"

@hibernate.collection-key
column="AQQC_GUID"

@hibernate.collection-one-to-many
class="com.nilu.adacs.hibernate.AQQC_QUALITYCONTROLLEVELFLAG"
</meta>
<key>
<column name="AQQC_GUID" />
</key>
<one-to-many
class="com.nilu.adacs.hibernate.AQQC_QUALITYCONTROLLEVELFLAG"
/>
</set>
<!-- bi-directional one-to-many association to AQQA_QAFLAG -->
<set
name="AQQA_QAFLAG"
lazy="true"
inverse="true"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"

@hibernate.collection-key
column="AQQA_GUID"

@hibernate.collection-one-to-many
class="com.nilu.adacs.hibernate.AQQA_QAFLAG"
</meta>
<key>
<column name="AQQA_GUID" />
</key>
<one-to-many
class="com.nilu.adacs.hibernate.AQQA_QAFLAG"
/>
</set>
<!-- bi-directional many-to-one association to AQQC_QUALITYCONTROLLEVELFLAG -->
<many-to-one
name="AQQC_QUALITYCONTROLLEVELFLAG"
class="com.nilu.adacs.hibernate.AQQC_QUALITYCONTROLLEVELFLAG"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="AQQC_GUID"
</meta>
<column name="AQQC_GUID" />
</many-to-one>
<!-- bi-directional many-to-one association to AQQA_QAFLAG -->
<many-to-one
name="AQQA_QAFLAG"
class="com.nilu.adacs.hibernate.AQQA_QAFLAG"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="AQQA_GUID"
</meta>
<column name="AQQA_GUID" />
</many-to-one>

</class>
</hibernate-mapping>

========================================

So, for some reason I get triple the number of columns. Has anyone else had this error?

I would be very greatful for a reply.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 7:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I have never seen this before. Very strange.

I would like you to remove the table tags in the Ant task as I have not verified (eg tested) it using any table definition tags. I think there is some confusion here with Middlegen provide incorrect table column data when its been remapped by the tags. Tell me how you go.


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