-->
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: multi-client database design with hibernate?
PostPosted: Tue Nov 02, 2004 4:27 am 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
Hello !

Our web-application is multi-client capable.
We have a database where every table has a composite-key with a client-number as first field.
Now after fiddle a little bit with a bug in the second-level cache [1], [2] Gavin finally means this is a bad database design.

Now I would like to now why?

What is the alternative to this design?

Should every client have its own scheme in the database?
Then every database change needs to be done in all schemes.

Comment are very welcome.

[1] http://opensource.atlassian.com/project ... se/HB-1280
[2] http://forum.hibernate.org/viewtopic.php?t=935627

--
Mario


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 5:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Look in the Hibernate Action book about the discussion of putting buisness meaning into primary keys.

Furthermore what Gavin said was:
"A SessionFactory per "company number" sounds like very bad or at least incredibly unusual application design."

And I fully agree - why would you want this ? Why don't you use the same cache for this multiclient app ? They won't collide since they have seperate identies!

What I do see a point on though is if you have colliding identifiers for the same tables in the singleton cache - then you will have a problem (no matter if you have your design or not)

But didn't your patch fix that ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 6:22 am 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
First of all, yes - I currently read the book - a great work!

This companyNumber or client-id strictly partitions the database.
Thus if the data for one company (client-id) changes due to update/insert there is no need to flush the (second level) cache for the other company.
This is what happens currently if you use only one SessionFactory (or do not use the region_prefix)- the second-level cache is invalidated.

This is why I wanted to create a SessionFactory per companyNumber. IMHO a must have for such a multi-client capable web-application.

And yes, the patch fixes it and a workaround to handle the cache-configuration hell is also possible. But even this workaround is not needet if the cache behaves as documented - every SessionFactory should have its own second-level cache. But I can live with it.

I just want to learn how such a database could be designed better.


I also see problems in NOT using composite-keys if hibernate tries to create its own ids.
I think this is not possible if you use multiple SessionFactories against the same database. For sure, then server generated ids are requied.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Wed Feb 10, 2010 5:44 am 
Newbie

Joined: Wed Feb 10, 2010 5:40 am
Posts: 1
max wrote:
Look in the Hibernate Action book about the discussion of putting buisness meaning into primary keys.

Furthermore what Gavin said was:
"A SessionFactory per "company number" sounds like very bad or at least incredibly unusual application design."

And I fully agree - why would you want this ? Why don't you use the same cache for this multiclient app ? They won't collide since they have seperate identies!

What I do see a point on though is if you have colliding identifiers for the same tables in the singleton cache - then you will have a problem (no matter if you have your design or not)

But didn't your patch fix that ?
Agreed great.

_________________
รับออกแบบเว็บไซต์ : web design : email marketing : SEO


Top
 Profile  
 
 Post subject: Re: multi-client database design with hibernate?
PostPosted: Tue May 28, 2013 2:10 am 
Newbie

Joined: Tue May 28, 2013 2:08 am
Posts: 1
I see problems in not using composite-keys if hibernate tries to create its own ids. I think this is not possible if you use multiple Session Factories against the same database.


phoenix database design professional


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.