[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Understanding how to organise data in Jboss

conpulpa do-not-reply at jboss.com
Tue Nov 11 05:57:57 EST 2008


 Dear Jboss enthusiasts,

 I'm look for some ideas on ways to improve our use of JBoss to represent our data. I'll describe our "simple" use of jboss and provide some pseudo code.

 Our current setup is as follows:
 
 Our database has two tables 
 
 a) group_product which provides a mapping between groups and products. A product can belong to more than one group.

 group_product table
 --------------------
 oid  group   product
 925  169535  637092
 926  169535  637093
 927  169535  637094
 928  169600  637094


 b) product which provides details about products

 product table
 -------------
 oid    name           
 637092 strawberry
 637093 apricot
 637094 raspberry
    

 In our Java application we use GroupProduct objects and Product objects to reprsent the data and our logic is to look in the cache before 
 going to the database when performing reads. We use Jboss treecache to represent this data and pull data for the cache using something 
 like this:-
 
 public List getGroupProducts(List groupProductIds) {
   List gp = new ArrayList();
   for (Integer id : groupProductIds) {
      gp.add((GroupProduct)getFromCache(groupProductFqn, id)) 
   }
   return gp;
 }

 public List getProducts(List productIds) {
   List p = new ArrayList();
   for (Integer id : productIds) {
      p.add((Product)getFromCache(productFqn,id)) 
   }
   return p;
 }

 private RepositoryEntity getFromCache(Fqn fqn, Integer oid) { 
  RepositoryEntity entity = cache.getCopy(fqn, oid)
  return entity;
 }
 

 Here the fqn is the FQN of the table and the index is the oid of the table.
 
 Now, if I want to get all the products from a collection of groupProducIds, I have to do the following
 1. Get all the GroupProduct Objects for the collection of groupProductIds
 2. for each GroupProduct Object get the product  
 3. for each product, get the product data

 My main concern with this design is that its inefficient because its getting data from the cache
 oid-by-oid and the cache is using locking everytime we pull data from it. Of course, we will benefit
 from MVCC in Jboss version 3, but for now we are using version 2 and i'm looking for ways to improve the 
 design by making fewer get calls. However, we also have to maintain the information in the cache, which
 means adding/removing new group-product mappings and products.

 Can we better organise how Jboss represents the data?

 Many thanks, for your ideas!


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188421#4188421

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188421



More information about the jboss-user mailing list