-->
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.  [ 1 post ] 
Author Message
 Post subject: Any property type with restricted values
PostPosted: Sat May 23, 2009 2:46 pm 
Newbie

Joined: Mon May 19, 2008 2:30 am
Posts: 2
HI, this is the first I would post on Hibernate forums although I have found many answers on them.
Ok, here's my problem: I'm using Type Square pattern for which I've created 4 classes. These are:
Product, ProductType, AttributeType and Attribute.
The idea of all this is to be able to create products (with their corresponding attributes) at runtime. Otherwise, I'll need to create a table and a class per product.
To sum up:
- Product holds information about an instance of a product (id = "123")
- ProductType holds information about its actual type (eg.: name = "Book")
- AttributeType is the type of attribute (eg.: name = "author", clazz = "java.lang.String")
- Attribute holds the value for a certain AttributeType and its related to a Product object (eg.: value = "John Doe")

With such information, here's my mapping:
Many Products - One ProductType

One ProductType - Many AttributeType

One AttributeType - Many Attribute

Many Attribute - One Product

It obvious that "value" in Attribute class should be of type Object. However I do not know how to declare that at runtime it should be mapped to "clazz" in class AttributeType. Does it make sense at all?

Now, appart from that, for certain attributes, I need to restrict the allowed values. For instance, some attribute can be of type String, and its value can be "high", "medium" or "low", an that's it. Should I achieve that with Strategy pattern? Or is there any hibernated-way to do so?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.