-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate use for dynamic languages
PostPosted: Wed Mar 02, 2005 11:34 am 
Newbie

Joined: Wed Mar 02, 2005 11:05 am
Posts: 5
Hello everybody !

I just started to play with Hibernate 3 and was very happy to see the new dynamic mapping feature (no need for POJO classes anymore, when you want to do something dynamic). I am currently investigating how to integrate Hibernate into a Java based dynamic language, which I am just creating.

Up to yesterday I was really planning to dynamically generate POJO bytecode out of my object definitions, generate the mapping XML and pass all this to a Hibernate Configuration object. Crazy!

But this new feature could make my life a lot easier.

So I spent some hours digging into the source to see, where those maps are instantiated and found class DynamicMapInstantiator. (together with POJOInstantiator etc.)

Now I should explain what I want to do:

My dynamic objects all implement the Map interface, but of course they can do additional fancy things. There is something like a factory, that creates dynamic objects by their type name:

Code:
class Factory
{
    static java.util.Map create(String typeName);
}


Now Hibernate creates HashMap instances. Of course I could take this instance, lookup the property "type" and then create my fancy object myself. But this would not work for related objects. I would have to walk the whole object graph and replace the hashmaps with my favoured objects.

So I was considering to just patch class DynamicMapInstantiator to return my kind of object. Since it implements the map interface everything should be fine (although I am not sure about side effects here)

Otherwise it could be smarter to slightly modify the DynamicMapInstantiator to allow for a user defined map factory.

Now my questions:

    - would such a change have a chance to be accepted?
    - how dangerous is it? (I am certainly not a Hibernate guru)
    - is the new dynamic feature usable for all kinds of mappings already?
    - if not, what are the current restrictions (I saw some TODO's regarding components.)


Any feedback is highly appreciated.

Best regards

_________________
MrLongleg
------------------------------------------
Life is too short to drink bad wine ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 11:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well there are certainly some things we would like to expose for further configuration regarding this stuff from within the mapping file.

Certainly custom Instantiators make sense. Eventually a way to plug in custom Tuplizers (which is the thing "above" Instatiator that govern a particular "entity mode").

In the meantime, it should be completely safe to simply patch how the DynamicMapInstantiator does its thing.

Quote:
- would such a change have a chance to be accepted?

Depends on how it was done and how well it was done ;)

Quote:
- how dangerous is it? (I am certainly not a Hibernate guru)

See above.

Quote:
- is the new dynamic feature usable for all kinds of mappings already?

Not sure what you mean.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 4:55 am 
Newbie

Joined: Wed Mar 02, 2005 11:05 am
Posts: 5
Thanks for your reply, Steve ;-)

I will try to understand the Tuplizer stuff, maybe I can create some kind of a solution.

For the maps I was wondering, if they already work with components. I saw some TODO's in the source code, although I cannot figure out (yet) what remains to be done.

_________________
MrLongleg
------------------------------------------
Life is too short to drink bad wine ;-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.