-->
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.  [ 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  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.