-->
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.  [ 5 posts ] 
Author Message
 Post subject: Middle out strategy and repeated mapping w/o UserType
PostPosted: Fri Feb 20, 2004 10:07 am 
Newbie

Joined: Fri Feb 20, 2004 9:46 am
Posts: 7
Location: Brazil
This is part of the mapping I use to generate Java code and sql ddl:

<class name="Business" table="business">
<id name="bsnId" type="int" unsaved-value="null">
<generator class="native"/>
</id>
...
<component name="bsnAddress" class="Address">
<property name="address" column="address1" type="string" length="64"/>
</component>
...
</class>

<class name="Entity" table="entity">
<id name="entId" type="int" unsaved-value="null">
<generator class="native"/>
</id>
<many-to-one name="business" class="Business" column="bsnId"/>
...
<component name="entAddress" class="Address">
<!-- I would not like to repeat the properties below -->
<property name="address" column="address1" type="string" length="64"/>
</component>
</class>

I would not like to repeat the lines noted above in the second class. I also discarded the subclass or joined-subclass options because I don't want to join business and entity in the same table. I would also like to have hbm2java to generate the Address class, what makes it difficult to use a UserType. Is it possible?

Thanks.

PS: I use hibernate 2.1


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 11:00 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 6:13 pm 
Newbie

Joined: Fri Feb 20, 2004 9:46 am
Posts: 7
Location: Brazil
Thanks anyway. I tought it might be a good idea.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 10:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You could try using XMLs feature of importing segments of XML.

Code:
<!DOCTYPE component [
    <!ENTITY address SYSTEM "file:./component/mapping/address.xml">
]>


This XML (include) file has the property lines in it for you component. eg:
Code:
<property name="address" column="address1" type="string" length="64"/>

Then in you mapping doco:
Code:
<component name="bsnAddress" class="Address">
&address;
</component>


Note: This is using the XML parser's features not a Hibernate feature.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 21, 2004 7:22 am 
Newbie

Joined: Fri Feb 20, 2004 9:46 am
Posts: 7
Location: Brazil
Thanks.

I was planning to use an ant task to pre-process the mpping file but your suggestion seems to be easier.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.