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.  [ 2 posts ] 
Author Message
 Post subject: Dynamic Runtime Mapping
PostPosted: Thu Aug 17, 2006 3:50 pm 
Newbie

Joined: Thu Aug 17, 2006 3:31 pm
Posts: 9
I inherited a DB Schema that stores product information on a per seller basis. The problem is, each seller gets their own product table. Each product table is identical in schema, but a new table is generated each time a new seller is added to the application, resulting in tables like:

Product111111
Product222222
Product333333
Product..........

Where 111111, 222222, are Seller IDs.

Aside from the atrocious DB design which I must conform to my question is this:

Is there anyway at runtime to query this type of schema? Options I have considered:

When I initially create the SessionFactory, dynamically add mappings for all Product..... tables. The only problem here is detecting when a new Seller is created and re-generating the SessionFactory.

Creating a SessionFactory per Seller??? When I need to query Products for a given Seller create a fresh SessionFactory or retrieve a cached SessionFactory with only the Product.... mapping.

Are they any Hibernate tricks/advanced uses that could help me with this situation?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 8:33 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
You didn't mention what db engine are you using.
For SQL Server:
1. I would build a view which unions all the Productxxxx tables.
2. I would try to redefine the view each time a new Seller is created.

Cheers,
radu


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