-->
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: HashMap / Enum keys as columns? Non-finite columns
PostPosted: Sat Oct 29, 2005 3:35 pm 
Newbie

Joined: Sat Oct 29, 2005 3:04 pm
Posts: 2
I'm currently developing an application that has some interesting constraints and am evaluating if Hibernate is the right persistence mechanism to use. The application stores a large number of individual names and attributes about these names. Each individual, or "Entity", can have a number of vary attributes that describe the Entity. The number of attributes, theoretically, is not finite. For example, Entity A may have 6 attributes, such as Name, Address, or City. Entity B may have 7 attributes, such as Name, Address, DOB, SSN etc. Note Entity A does not track DOB or SSN (would be NULLs in a DB if stored in one big table). As more and more information is gathered about these Entities, the number of attributes is virtually limitless. Currently, there can be over 40-50 attributes per Entity and growing. Any individual Entity uses an arbitrary subset of these attributes. This is also compounded by the problem that an entity can have multiple values per attribute. For example, an Entity can have 5 values for Alias attribute.

Programmatically, we are looking to tackle this issue by having an HashMap that stores an Enum value for the attributes as key and the value of that attribute. For example

public class Entity {
private Map attributes = new HashMap();
public addAttribute(AttributeEnum key, String value) {
attributes.put(key,value);
}
}


enum Attributes {
LastName,
FirstName,
Address1,
Alias1,
Alias2,
}

public class UseCase {
public static void main(String[] args) {
Entity entity = new Entity();
entity.addAttribute(Attributes.LastName, "Johnson");
entity.addAttribute(Attributes.Alias1,"Joey");
}
}

Although we are still grappling with the idea of multiple values for a particular attribute (i.e. Alias1, Alias2... AliasN, seems ugly and is an issue), some questions arise

1. How would/Can Hibernate persist an Entity object?
2. What DML would Hibernate create for such a relationship?
3. Are there any other design suggestions to ease persistence given the constraints (near limitless attributes, possible multiple values per attribute)?
4. A relational DB may not be ideal, this may be a job for an XML or LDAP repository. If using an XML db, what changes need to be made in the program design to make Hibernate work?
5. Assuming a relational DB is mandated, what are the options that Hibernate provides?

Thanks very much


Top
 Profile  
 
 Post subject: Slight correction
PostPosted: Sat Oct 29, 2005 3:51 pm 
Newbie

Joined: Sat Oct 29, 2005 3:04 pm
Posts: 2
This line

public addAttribute(AttributeEnum key, String value) {

should be

public addAttribute(Attributes key, String value) {

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.