-->
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.  [ 5 posts ] 
Author Message
 Post subject: generic class to hold mapped data for dynamic data models
PostPosted: Sat Jan 31, 2004 8:41 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
I have a somewhat unique requirement:

our database can be enhanced by the client - so in my application
I do not control all the tables. However, I can dynamically
determine the table and column names, PK and FK relationships.

Short of dynamically generating the required class and the
the mapping - how can I use Hibernate to dynamically define
a mapping (which I think I can) and use a generic class to
be populated by my hibernate queries (which I think is not
_officially_ possible).

I can easily come up with some List of Maps populated from a
ResultSet to achieve the same in a pedestrian fashion, but our
goal is to achieve the same using O/R mapping in Hibernate
to leverage its navigational and transactional capabilities.

For instance, assume a simple model
P <[1]--[1]> C1 <[n]--[1]> C2

Here P is a fully supported core Class and C1 and C2
are not known in advance. I would need to:
A) inject the 1:1 relation between P and C into Ps mapping,
B) dynamically define mappings for C1 and C2 as well as
one-to-many relationship between them.
All this has to happen at the client site in a live database,
without my intervention, adding and modifying any number of C* tables.
I think that generating interfaces for these C* tables could
be done, but not full-blown classes.

Here are a couple dreamt-up ways to achieve that:

1) Allow an interface as the implementing class, in conjunction
with a factory Class to obtain implementations.
Sounds similar to the existing use of proxies, with the difference
that I would like to supply the factory myself and that this is
not related to lazy initialization.
2) Allow to map to a generic holding object (Class will
be mapped to several tables and thus needs to capture
the table name in the mapping so that the query language
can use it)

It think I have seen a few posts regarding <dynamic-components>
at the highest level and the like. I hope that my case can convince
the team to start a debate about what that means.

Of course, given a generic holding object, supporting generation
of XML/JDOM/... representation of the object is very simple,
which is another reason why I would like to see this model supported.

Any pointers are very much appreciated.

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 9:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This has been discussed on the forum. Have a look.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 4:34 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
Hmmh, yeah, sorry, I'm dense.

I spent several hours looking.

Just because something has been discussed somewhere sometime, by someone, read by somebody, who remembers it,
doesn't mean it becomes public knowledge, or is easy to find.

If it _was_ easy to find, and I _got_ a clue from that somebody,
I _might_ apologize for not having looked harder.

So let's say I look for another couple of hours and then delete my
account.

Chiao.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 5:38 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
I'll be lookng at v22 <dynamic-class>.

Any comments on that in view of my use case?

To complicate matters, due to Q/A and release
schedules, we might have to transition from <dynamic-component>
to <dynamic-class> later.

Does that look like a smart idea?

Thanks.

Martin

Btw. I researched the forum, and indeed the matter
_has_ been discussed before, but not really _solved_
till now.

Understandably, as O/R mapping by its purpose and
history is more concerned with _existing_ classes and tables,
but I'm excited about Hibernate's new generic capabilities.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 6:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Here is a summary of Dynamic capabilities of Hibernate. I'm not that good on that topic, so don't expect everything to be true until it's re-read.
http://www.hibernate.org/171.html

_________________
Emmanuel


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