-->
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.  [ 4 posts ] 
Author Message
 Post subject: Extension points - Tupilizer/Instantiator/EntityMode
PostPosted: Mon Mar 07, 2005 10:43 am 
Regular
Regular

Joined: Mon Feb 23, 2004 10:42 pm
Posts: 102
Location: Washington DC
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.0 rc1

I am trying to extend the Hibernate framework to allow me to read and write my own custom version of what essentially is a Map. I used to use the Interceptor just fine with Hibernate3 Beta 1, but it is not working anymore.

I did some digging to find new interfaces, Tupilizer and Instantiator. Can you provide some feedback as to how to use these and where I can plug them into the framework? I have created a Tuplizer and Instantiator for my custom objects, but can't find the place to plug them in. Is there a way to create my own EntityMode?

Code:
Configuration config = new Configuration().configure( new File( hibernateConfigFile ) );
config.setInterceptor( new MetaObjectInterceptor() );

sessionFactory = config.buildSessionFactory();

MetaKit metaKit = new MapMetaKit( null );
MetaObject metaObject = metaKit.getMetaObjectFactory().createMetaObject( metaClass );
metaObject.setProperty( "name", "Engine 611" );
metaObject.setProperty( "unitType", "Engine" );
metaObject.setProperty( "stationNumber", new Integer( 11 ) );
metaObject.setProperty( "gallonsOfWater", new Integer( 750 ) );
metaObject.setProperty( "singleAxle", Boolean.TRUE );

Session session = sessionFactory.openSession();
Session mSession = session.openSession( EntityMode.MAP );
Transaction tx = session.beginTransaction();
mSession.saveOrUpdate( metaObject );
session.flush();
tx.commit();
session.close();

_________________
Matt Veitas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 9:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Eventually these will be extension points hopefully. Currently they are not per-se. To use them you'd really have to modify the Hibernate sources. Specifically, take a look at persister/BaseEntityPersister and tuplizer/TuplizerLookup. The easiest option would be to simply modify the MapTuplizer stuff to perform your needed functionality.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 9:35 pm 
Regular
Regular

Joined: Mon Feb 23, 2004 10:42 pm
Posts: 102
Location: Washington DC
I think that I have a stop gap solution until the Hibernate team makes these extension points, someday ;). Not sure if there are plans for documenting the extension points in more detail, but I think that would be a great addition to the reference docs.

The functionality that we are looking for with Hibernate to do the reading/writing of these custom objects is minimal. What I have done is to create my own Tuplizer and Instantiator, and then extend SingleTableEntityPersister to create use the custom Tuplizer that I created. So far simple reads and writes of objects work just fine. I am going to look into more complex things like components and such this week.

Great work with Hibernate 3 so far....I can't wait to start using some of the new features!

_________________
Matt Veitas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 10:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well there's always plans to document extension points; but like I said these are not currently intended as extension points ;)


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