-->
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: AliasToBeanResultTransformer and Projection.count Problem
PostPosted: Sat Dec 20, 2008 1:46 pm 
Newbie

Joined: Tue May 22, 2007 2:12 am
Posts: 9
Hi,

I am firing a query in which i want to extract the "calling number","called number" and count of "called number" from database.

I've written the following query ---



Code:
public List getCallDetsForReport(Map objectArgs)
   {
      logger.info("start of call details records");
      List dataList = null;
      try
      {
         String callingNum = (String)objectArgs.get("callingNumber");
         callingNum = "9829576509";
         Session hibSession = getSession();
         Criteria criteria = hibSession.createCriteria(HdCallDetailRecords.class);
         criteria.setProjection(Projections.projectionList()
               .add(Projections.property("callingNumber").as("callingNum"))
               .add(Projections.property("calledNumber").as("calledNum"))
               .add(Projections.count("calledNumber").as("countCalled"))
               .add(Projections.groupProperty("calledNumber"))
               );
         criteria.add(Restrictions.eq("callingNumber",callingNum));
         criteria.setResultTransformer(new AliasToBeanResultTransformer(CallDetailsRecCustomVO.class));
         dataList = criteria.list();
         System.out.println("the list size here is "+dataList.size());
      }
      catch(Exception e)
      {
         logger.error("the error has occured"+e);
         e.printStackTrace();
      }
      return dataList;
   }




The custom VO Class looks like this --

Code:
public class CallDetailsRecCustomVO
{
   
   private String callingNum;
   
   private String calledNum;
   
   private Integer countCalled;


   /**
    * @return the calledNum
    */
   public String getCalledNum() {
      return calledNum;
   }

   /**
    * @param calledNum the calledNum to set
    */
   public void setCalledNum(String calledNum) {
      this.calledNum = calledNum;
   }


   /**
    * @return the callingNum
    */
   public String getCallingNum() {
      return callingNum;
   }

   /**
    * @param callingNum the callingNum to set
    */
   public void setCallingNum(String callingNum) {
      this.callingNum = callingNum;
   }

   /**
    * @return the countCalled
    */
   public Integer getCountCalled() {
      return countCalled;
   }

   /**
    * @param countCalled the countCalled to set
    */
   public void setCountCalled(Integer countCalled) {
      this.countCalled = countCalled;
   }


as clear from above code snippets, i want to populate the custom vo with the folowing details --
1. calling number.
2.called number
3. no of calls from calling number to called number.


On executing this query it gives me an exceptionsaying arguement mismatch while applying setter of "countCalled" property of my "CallDetailsRecCustomVO " . can someone help me in this regard ???


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.