Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:44:14+00:00 2026-06-17T09:44:14+00:00

I have two entities Issue and Issue_Tracker . I have joined both table in

  • 0

I have two entities Issue and Issue_Tracker. I have joined both table in an one to many mapping. In Issue_Tracker , We can have multiple entries like

  issue_id  tracker_status      tracked_time
    123     Assigned           1/8/2013 11:44
    123     Assigned           1/8/2013 11:45
    123     Completed          1/8/2013 11:52
    32      Assigned           1/9/2013 16:46
    33      Assigned           1/9/2013 16:47
    33      Cancel             1/9/2013 16:49 

I want to Order the Issue_tracker entity by tracked_time so I can get only last update tracker_status.I am using criteria to get data,However I am getting first entry for example : for issue_id 123, I get tracker_status as Assigned , But I want to fetch tracker_status : Completed for id 123. How to achieve this. My DAO is as follows

     Criteria criteria = session.createCriteria(Issue.class);
     criteria.setFirstResult(from);
     criteria.setMaxResults(size);
     criteria.setFetchMode("Issue.issueTracker",FetchMode.JOIN);
     criteria.add(Restrictions.eq("status", "Escalate To"));
      return criteria.list();

Issue.java

public class Issue implements Serializable
        {
        private Integer issue_id;
        private String  issue_description;
        private Date issue_raised_date;
        private Set<Issue_Tracker> issueTracker = new HashSet<Issue_Tracker>(0);



        @OneToMany(fetch=FetchType.LAZY, mappedBy="issue_id")
        public Set<Issue_Tracker> getIssueTracker() {
        return issueTracker;
    }

        public void setIssueTracker(Set<Issue_Tracker> issueTracker) {
        this.issueTracker = issueTracker;

Issue_Tracker.java

public class Issue_Tracker implements Serializable
{  
     private Integer   issue_id;
     private String    tracker_status;
     private Timestamp tracked_time;

I hope you guys can get what i am trying to ask, any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:44:14+00:00Added an answer on June 17, 2026 at 9:44 am

    Add an @OrderBy annotation to the mapped collection. This should return the entities in the set ordered by the tracked time. The first entity in the set should be the latest.

    //Issue.java
        @OneToMany(fetch=FetchType.LAZY, mappedBy="issue_id")
        @OrderBy("tracked_time DESC")
        public Set<Issue_Tracker> getIssueTracker() {
        return issueTracker;
    

    You may also want to try:

     Criteria criteria = session.createCriteria(Issue.class);
     criteria.setFirstResult(from);
     criteria.setMaxResults(size);
     criteria.setFetchMode("Issue.issueTracker",FetchMode.JOIN);
     criteria.add(Restrictions.eq("status", "Escalate To"));
     Criteria subCriteria = criteria.createCriteria("issueTracker");
     subCriteria.addOrder(Order.desc("tracked_time"));
     return criteria.list();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two Entities, Parent and Child, that are linked through a bidirectional one-to-many
I have two entities Issue and Issue_Tracker . Issue.java: public class Issue implements Serializable
I have two entities involved in this issue. A user can have an event
I have two entities: Article and Category. That have a many to many table:
I have two entities like this: public class Service { public virtual int ServiceId
I have two entities: Patient and Job. Patient has a to-many relationship to Job
I have two linqTOsql entities that has a parent and child relationship, one to
I have two entities: Group and ContactInfo. These are connected with a many-to-many relationship
I have a many to many relationship between entities and there is a table
hi i have two entities User and Authority they have many to many relation:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.