-->
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: HIBERNATESHARD-How can I shard database with multi table ???
PostPosted: Thu Aug 11, 2011 4:12 am 
Newbie

Joined: Thu Aug 11, 2011 3:46 am
Posts: 3
i has 2 table in my database : EMPLOYEE and DEPARTMENT like this picture --> Image

In table EMPLOYEE has column LOCATION and i want to shard this table by LOCATION :
Example : if employee has LOCATION " France " --> shard0 , "USA" --> shard1, "singapore" --> shard2 ....

Here is my code :
Code:
public ShardId getShardId(String _location)
      {
         int shardId = 0;
        
         if(_location.equalsIgnoreCase("VietNam"))
            shardId = 0;
         else if(_location.equalsIgnoreCase("Singapore"))
            shardId = 1;
         else if(_location.equalsIgnoreCase("USA"))
            shardId = 2;
         else if(_location.equalsIgnoreCase("France"))
            shardId = 3;
        
         return new ShardId(shardId);
      }


if i shard with 1 table EMPLOYEE , it run successfully, BUT, when i shard it with table DEPARTMENT , it is wrong :(. It doesn't shard by LOCATION.

It return a shard with DEPARTMENT. it mean : if I has 2 employee with different LOCATION and the same ID_DEP (same DEPARTMENT) , if i shard only 1 Table EMPLOYEE by LOCATION, 2 employee will insert into different shard, BUT if i shard with 2 table EMPLOYEE and DEPARTMENT by LOCATION, 2 employee will insert into same shard :((.

Please help me. sr i has bad english :((.


Top
 Profile  
 
 Post subject: Re: HIBERNATESHARD-How can I shard database with multi table ???
PostPosted: Thu Aug 11, 2011 4:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

are you actually using Hibernate Shards? With which version of Hibernate. I don't know much about Hibernate Shard, but it is not actively developed/used anymore. You should read these blogs http://relation.to/Bloggers/MultitenancyInHibernate and http://relation.to/Bloggers/HibernateAn ... ncyWebinar . These blogs talk about how to achieve sharding with the latest versions of Hibernate.

--Hardy


Top
 Profile  
 
 Post subject: Re: HIBERNATESHARD-How can I shard database with multi table ???
PostPosted: Mon Aug 15, 2011 5:28 am 
Newbie

Joined: Thu Aug 11, 2011 3:46 am
Posts: 3
thank sir, but i must use hibernate shard, can you give me any ideas to solve that problem, plz


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.