-->
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: Customizing entity classes without changing code or schema
PostPosted: Fri May 15, 2009 1:54 pm 
Newbie

Joined: Sun Dec 04, 2005 2:24 pm
Posts: 9
I have a problem where a general software product needs minor customizations for different customers. A core entity class (let's say "Article") is 90% common to all clients, but each customer needs a few additional customized fields.

I would very much like to keep the core of the application 100% identical for all customers and to facilitate customizations by way of plugins and configuration files. Also I would like to keep the database schema 100% identical for all customers.

I was thinking that in addition to the common properties (eg title, author, publishDate, etc) which can be accessed via the traditional getter/setter methods there would be a bundle of Properties which are defined by a configuration file. Eg:

<custom-properties>
<property name="article.familyFriendly" datatype="boolean" />
<property name="article.commentsAllowed" datatype="boolean" />
<property name="article.cost" datatype="integer" />
</custom-properties>

In the code, to access a custom property I would use something like this:

Map<String,PropertyValue> properties = myArticle.getProperties();
and
Integer cost = (Integer)myArticle.getPropertyValue("article.cost");

In the database I would have a properties table with columns for entity_id, property_name, property_value


If properties were strings and only strings this would be trivial to implement in Hibernate. However there are complications:

a) Custom properties can have multiple data types (boolean, integer, string and possibly other types such as date, enumarations etc)
b) I must be able to query for objects using these properties as criteria in the query eg
from Article as article
join article.properties as property
where property.name='article.cost'
and property.value<45
c) There may be a requirement to add property value constraints (eg integer min and max values etc)

I have a partial solution implemented in Hibernate, but some of the implementation details are ugly. So before I invest much time in possible wheel reinvention, has this been done before? Or, if not, can anyone suggest other elegant solutions to this general problem?

Thanks in advance,

Joe.


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.