-->
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: How to handle Metadata driven/dynamic entities in Hibernate
PostPosted: Thu Jan 03, 2008 4:28 am 
Newbie

Joined: Wed Jan 02, 2008 5:05 am
Posts: 2
The current version of my application has fixed set of entities as it is developed for use by users of a specific (pharmaceutical) domain.

Now we wish to enhance it to be used by users from other domains (finance, instrumentation).We need to provide a metadata driven system, where entities will be decided by the administrator of application on the fly.
The example case is :
Presently we have fixed entities such as Brand, Region, TherapeuticArea, Topic. All of these entities are functionally categorized as Objectives. There are fixed classes, mapping files for each of them (and fixed tables with relationships among them).So the entity-relationship is static in nature as in any standard application.
In future we will know only one entity 'Objective'. Administrator should be able to create any Objective type entity such as Brand, Region etc, on the fly. He can also specify relationships among them(in most of the cases it is many-to-many relationship).Then these entities should be used as application level entities and user will be able to store their instances, update them as well as delete them.

There are two ways I can think, this can be achieved
1.Creating an entity "Objective" with fixed set of attributes with a "type" attribute, to describe type of entity(brand or region etc).In this case defining the relationships among the entities will be a challenge.

We will need a separate mapping table to map the many-to-many relationships between these entities. Consider following class

Class Objective {
Long Id
attribA;
attribB;
type;
Set <Objective>parents; //many-parents
Set <Objective>children; //many children
}

If I create a mapping table say “Objective_Mapping” it will have both keys from the same entity i.e. Objective. How can write an hbm.xml file for such a configuration?

2.The second option is to create the entity classes (Brand, Region) and respective hbm.xml files on the fly and use them in application at runtime. Is this possible using “Configuration” class API ?


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.