Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: projections on multiple tables
PostPosted: Sun Aug 05, 2012 1:23 pm 
Newbie

Joined: Sat Jun 23, 2012 10:03 am
Posts: 3
i have a orders table, order_status table and a system_codes table.

one order will have a 1 order_status. there is one to one between these 2 tables.

i have a one to one between order_status ---> system_codes. every order status will have a unique system_code (in fact the order_status and system_code is the the same)

there is no direct relationship between order and system_codes. So, my question is how to access a column from system_codes table using projections

some code i have is as follows.

Code:

                ProjectionList columnList = Projections.projectionList();
      columnList.add(Projections.property("id"), "id");
      columnList.add(Projections.property("orderStatus"), "orderStatus");
      columnList.add(Projections.property("orderTodate"), "orderTodate");

      crit.setProjection(columnList);

      crit.createAlias("lineItems", "li");
      columnList.add(Projections.property("li.id"), "itemId");
      columnList.add(Projections.property("li.itemStatus"), "itemStatus");
      columnList.add(Projections.property("li.procPriority"), "procPriority");
      columnList.add(Projections.property("li.activitySite"), "site");

      crit.createAlias("li.lineSources", "lsrc");
      columnList.add(Projections.property("lsrc.datasetName"), "dataset");
      columnList.add(Projections.property("lsrc.datatypeName"), "datatype");

      crit.createAlias("orderEmails", "orderemails");
      columnList.add(Projections.property("orderemails.EmailAddress"), "email");

      crit.createAlias("userId", "usr");
      columnList.add(Projections.property("usr.lastName"), "user");

      crit.setResultTransformer(Transformers.aliasToBean(OrdersCopa.class));

      return crit.list();



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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.