Announcement Announcement Module
Collapse
No announcement yet.
How select the return type ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How select the return type ?

    this.getHibernateTemplate().find("from r in class " + RecordVO.class + ", s in class "+StandardVO.class+
    " where r.recordId=s.recordId and "+
    " r.status='"+Constants.USED+"' and "+
    " add_months(r.lastUpdate, s.reviewPeriod) <= sysdate");

    This request works very well but the list which is returned contains an Object and not just a Record or just a Standard...

    I am lost !!!!

    Thanks

  • #2
    Normally, in those case, Hibernate should return a list of Object[]. But you can force the result value to your own composite type using the dynamic instantiation feature.
    Code:
    select new CompositeRecordStandardRecord&#40;r.id, r.status, r..., s.id, s...&#41; from " + RecordVO.class + " r, " + StandardVO.class + " s where ..."
    And you result list will be a list of CompositeRecordStandardRecord. Just be sure to create the right constructor to fit your need.
    HTH

    Olivier

    Comment


    • #3
      Thanks for this response but when I call this method (i.e. find(String)), I begin this-one by from, I can't begin by "select"

      Comment


      • #4
        Originally posted by anel69ka
        Thanks for this response but when I call this method (i.e. find(String)), I begin this-one by from, I can't begin by "select"
        What does hibernate complain about when you're using the select keyword as indicater sooner ?

        Olivier

        Comment

        Working...
        X