-->
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: How to map a component with subclasses?
PostPosted: Sat Mar 05, 2005 4:54 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

I'm trying to map Locale specific address and mobile number information. I'm having difficulty mapping the address and mobile, because address is a component for the user class and mobile is a component for the address class. I don't understand how to map a subclass within a component.

Assuming mapping this is possible, can it be mapped through xdoclet?

User.java - parent class
Subscriber.java - class containing component reference to Address interface. Subclass of User.java

Address.java - interface containing component reference to mobile.java. Mapped as component in the Subscriber class
AnAddress.java - abstract class
NLAddress.java - implementation class

Mobile.java - interface. Mapped as component in the Address interface
AMobile.java - abstract class
NLMobile.java - implementation class

Kind regards,

Marc


Top
 Profile  
 
 Post subject: Worked around it, but did not solve it
PostPosted: Sun Mar 06, 2005 10:18 am 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
After finding some references to this issue in the forum I tried creating a CompositeUserType, but I ran into a snag. My implementation class is locale specific (NLAddress, UKAddress, NLMobile, UKMobile etc).

The country code is stored in the user table. For a CompositeUserType, the returned class would therefore be dependent on the information read from the database. Since it seemed I could probably not get this to work, I resolved to violate the architecture a little.

In stead on making AnAddress and AMobile abstract classes, I made them concrete. Then, I added class="package.AnAddress" and class="package.Amobile" to the relevant hibernate.component reference.

I'm wondering if there is a way to do this without violating architecture principles. Especially, since the documentation suggests that a fine grained object model is the aim, and this seems not an uncommon architecture ;-) I did see some reference in the forum to extending the component class to support inheritance, but judging from the Hibernate 3.0 codebase this was never followed up on. I would have expected more references to this issue on the forums, which only suggests that I might be an idiot. I probably missed the obvious. I'd love to be enlightened.

Kind regards,

Marc


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.