-->
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: An issue with autogenerated mapping document
PostPosted: Tue Oct 14, 2003 12:51 pm 
Newbie

Joined: Tue Oct 14, 2003 12:27 pm
Posts: 2
Here's the story...

I ran Hibernate plugin for Middlegen against my database to generate mapping docs. Surprisingly, it ran fine ;-) (~350-table Oracle schema).

Then I ran hbm2java to generate POJOs... It didn't go as well as I expected. Having done some reseach, I traced the problem down to somewhat erroneous mapping file. Here it is:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//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="airline.hibernate.IncomeType"
table="INCOME_TYPE"
>
<property
name="description"
type="java.lang.String"
column="DESCRIPTION"
length="32"
/>
<id
name="incomeTypeId"
type="long"
column="INCOME_TYPE_ID"
>
<generator class="assigned" />
</id>
<property
name="code"
type="java.lang.String"
column="CODE"
length="32"
/>

<!-- associations -->
<!-- bi-directional one-to-many association to RegularFinancialEvent -->
<set
name="regularFinancialEvents"
lazy="true"
inverse="true"
>
<key>
<column name="INCOME_TYPE_ID" />
</key>
<one-to-many
class="airline.hibernate.RegularFinancialEvent"
/>
</set>

</class>
</hibernate-mapping>

The bad thing about the file above is it has 'id' element after 'property' element which violates the DTD.

I traced it down further into database. Here's the scipt that's used to create the table above:
CREATE TABLE income_type (
description varchar2 (32),
income_type_id number (10) NOT NULL,
code varchar2 (32),
constraint income_type_pk
primary key ( income_type_id ))

So it looks like the order of columns poses a problem to the plugin.

Am I doing something wrong?
Is it a known issue?

Thanks,
Borys


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 12:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The mapping is indeed wrong due to the property being before the ID. I do order placement of the elements as the version requires correct placement as well. I will check this and fix it if I find there is a bug.
For the moment one table of 350, you could rebuild the table.

BTW: Glad the plugin was able to surprise you with it processing 350+ tables.
It is great to get confirmation like this - thanks.


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.