-->
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.  [ 6 posts ] 
Author Message
 Post subject: Custom Type Safe Enumeration
PostPosted: Wed Apr 06, 2005 11:48 am 
Regular
Regular

Joined: Tue Nov 30, 2004 4:23 pm
Posts: 62
At my work we are creating a Type Safe Enumeration wrapper around a List. We are using JDK 1.4.2 and our wrapper holds an instance to List as opposed to implementing List and overriding its methods with our own type safe functionality.

I know it is mentioned in the Hibernate documentation that the superclasses for collections are preferred when mapping these collections in a *.hbm.xml. Will this type of Type Safe Enumeration cause problems when trying to map a class that has one of these Type Safe Enumeration collections of another object? Should we be implementing List as opposed to holding an instance, would this make a difference in the Hibernate mapping? Or is this purely a job for a custom type?

Thanks,

-jay


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 2:04 pm 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
Your terminology is a little confusing. Are you talking about a type-safe collection? Or an "enum" type (i.e. a value type) implemented as a class?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 2:07 pm 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
Or maybe a type-safe implementation of java.util.Enumeration?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 2:46 pm 
Regular
Regular

Joined: Tue Nov 30, 2004 4:23 pm
Posts: 62
Sorry...I am little retarded in this area.

We are trying to create Type Safe Collections. So for instance, we are creating implementations of a Collection that only allow the addition of a particular type of object. So we have a core TO that has these Type Safe Collections that hold different types of TOs. Each special TO has a special Type Safe Collection that only allows that type of object in the collection.

Therefore we may have a person TO that may hold a Type Safe Collection of Address TOs.

What would it take to represent in Hibernate?

Thanks,

-jay


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 2:06 pm 
Regular
Regular

Joined: Tue Nov 30, 2004 4:23 pm
Posts: 62
Would custom types work in this scenario?

Thanks,

-jay


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 2:22 pm 
Regular
Regular

Joined: Thu Nov 13, 2003 2:55 am
Posts: 71
Location: Sweden
Have you looked into Java 5 generics, and whether it can do the trick for you?

The reason for using the List/Map/etc interfaces in your POJOs is that Hibernate will then use it's own implementation allowing lazy initialization etc.

From what I remember you could use a concrete implementation (such as ArrayList) but I cannot really remember the effects of it. You probably loose some of the features (such as lazy initialization) and possibly some performance.


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