-->
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: Mapping multiple tables dynamically to one class (templates)
PostPosted: Tue Jun 27, 2006 7:46 am 
Newbie

Joined: Tue Jun 27, 2006 7:08 am
Posts: 9
I have multiple tables in the database with unknown schema and would like to use one class to manage their records. Where I should start to implement mapping at runtime?

Would it be possible to do something like the following using Hibernate (or I'm selecting wrong tool)? I'd like to use database meta data classes provided by hibernate and also to analyse relations in the database.

1. get names of tables from configuration file.
2. detect primary/foreign keys in the tables.
3. generete mapping to generic classes to store only primary/foreign keys in classes.
4. generate mappings to the *foreign/parent* records containing refferences to the child records.
5. use these generic classes to process generic queries (provided in some configuration files)

Questions:

Which classes to use to detect/analyse database schema, export it to the file, compare schemas/MetaDatas for two databases?

Which classes to use to generate mapping on the fly to bind tables with generic template classes.

Where I can find static class diagram for Hibernate mapping classes?

table1(id, col1, col2, col3)
=>
class Row<"table1"> {
Object id; // mapped to in the table
theRest; // mapped to all other data in the
}


=Database=

table1 (id, ...)
table2 (id, table1_id, ...)
table3 (id, ...)

=Class=

Row<String> : SomeInterface {
id
...
List getChildRows();
}

ChildRow<String> : SomeInterface {
id
prent_id
}

=Usage=

List results;

// assume that we will get list of object of the Row<"table1"> type
results = dao.getRows("table1", <some generic query>);

((SomeInterface)results.get(0)).doSomething();

... process results


Thanks a lot in advance!


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.