[hibernate-issues] [Hibernate-JIRA] Created: (HSHARDS-62) How can I shard database with multi table ??? (Multi tenancy )

Pham Hoang An (JIRA) noreply at atlassian.com
Mon Aug 15 23:30:02 EDT 2011


How can I shard database with multi table ??? (Multi tenancy )
--------------------------------------------------------------

                 Key: HSHARDS-62
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSHARDS-62
             Project: Hibernate Shards
          Issue Type: Deprecation
          Components: strategy
    Affects Versions: 3.0.0.Beta2
         Environment: Hibernate3 , hibernate-shards-3.0.0.Beta2, mysql-5.5.14-win32 
            Reporter: Pham Hoang An
            Assignee: Max Ross
         Attachments: Capture-2.png

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 :((.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list