-->
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: Request for Ideas: Contextual Customization
PostPosted: Thu Apr 27, 2006 10:23 pm 
Newbie

Joined: Thu Apr 27, 2006 10:09 pm
Posts: 4
Okay, here goes.

My company has a requirement that POJOs be customizable at runtime. We've put together a framework that allows POJOs to be created using a base implementation class that internally uses a HashMap to store additional properties that can be added at startup. (This allows for customization of our product in the field.) We provide our own property setters and getters to Hibernate to insure the base class's interface is used when necessary.

That's the easy part. The problem is, they now want for custom properties to be visible only in certain contexts. For instance, if a particular customer is selling products from multiple vendors, they may want to add property1 to instances of vendorA's products, and property2 to instances of vendorB's products. Different properties, different types, different rules. At first I suggested we simply add property1 and property2 to all instances and let the UI sort it out, but due to other constraints (real or perceived), they are pushing for a solution closer to the database.

My first thought was to dynamically create subclasses using CGLIB and register the subclasses using the "vendorID" as the discriminator. However, I'm having trouble wrapping my head around getting Hibernate to use the dynamically generated classes when necessary.

My second thought was to completely replace the EntityPersister to insert the appropriate columns when necessary. (The base class of our entities always guarantees storage for whatever properties we need, so the database side is the only part we need to worry about). However, the supplied EntityPersister implementations are not for the "faint of heart".

I am open to any and all suggestions.

Thanks,
Steve


Top
 Profile  
 
 Post subject: Current thoughts on this subject
PostPosted: Mon May 08, 2006 11:13 am 
Newbie

Joined: Thu Apr 27, 2006 10:09 pm
Posts: 4
Well, after much knashing of teeth and pulling out of hair, we've decided to foist the contextual customizability on to the application via explicit polymorphism. This does require us to have a physical subclass which we will still generate. It also requires the application to request the appropriate entity name when creating HQL. However, this will simplify the overall design to something we can achieve in the short term. We will simply create utilities that will make it easy to determine the correct entity name when constructing commands.

If anyone has a better idea, I'd love to hear it.


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.