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: Using hibernate-tools directly
PostPosted: Wed Dec 19, 2007 10:11 am 
Newbie

Joined: Mon Dec 10, 2007 6:46 am
Posts: 6
Does anyone know if there are any resources/documentation on using the hibernate-tools.jar classes directly (i.e. not through the Ant tasks or plugin)? I have an application where there are a number of known entities which are mapped (using JPA annotations), and there will also be a number of mappings which we need to be able to create at runtime. It seems this is possible using non-POJO mappings which Hibernate returns as Maps. We have to allow users to easily create these mappings though, and it seems a shame to build something proprietary when there is already a good tool to extract mappings (including relationships and other complex stuff). We need to be able to connect to the same database as the current Hibernate Session would and do the following;

1. Provide a list of (possibly filtered) tables in the database.
2. Reverse engineer specific tables *into some in-memory structure*
3. Save the result back into the database
4. Retrieve it at some later point, to be merged into the Configuration which creates the SessionFactory

Any ideas or pointers would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 2:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Note: hibernate tools internals is not a real fully public API, so just be aware changes might happen.

1) look in the unit tests for usages of MetaDataDialect and JDBCReader

2) use a ReverseEngineeringStrategy to specify which tables you want

3) I don't know what that means

4) Retreive what ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 20, 2007 11:21 am 
Newbie

Joined: Mon Dec 10, 2007 6:46 am
Posts: 6
Thanks - that looks like useful information. I'll give some things a go.

3 and 4 are just there because the mappings need to be *very* dynamic. So 3 would involve saving "something" (probably the XML of the generated <hibernate-mapping>) into one of the fixed tables or to a file. So, 4 would involve;

- getting hold of the saved dynamic mappings

- getting the default Hibernate configuration with all the fixed mappings using Configuration.configure()

- adding the dynamic mappings using something like Configuration.addInputStream() or .addDocument()

- getting a SessionFactory using Configuration.buildSessionFactory()


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.