1

I am using Struts 2.3.7, struts2-jquery-grid-plugin-3.5.0 and hibernate 3.6. I want to show data on jqgrid which is coming from two different tables.

My problem is that I have to show two tables data in one jqgrid .First three jqgrid column is filled by Issue table and last Column name="assignedTo" is filled by Issue_Tracker table. How to show the data in last column i.e. assignedTo. Any help would be appropriated.

My jqgrid is

<sjg:grid
    id="gridtable"
    caption="Issue-Summary"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="gridModel"
    rowList="10,15,20"
    rowNum="15"
    rownumbers="true"
    reloadTopics="reloadGrid"
>
    <sjg:gridColumn name="issue_id"  id="issueId"  index="id" title="Issue-ID" formatter="integer"  sortable="false"/>
    <sjg:gridColumn name="issue_description" index="id" title="Issue-Details"  sortable="false"/>
    <sjg:gridColumn name="issue_raised_date" index="date" title="Issue-Date"  formatter="date"  sortable="false"/>

    <sjg:gridColumn name="assignedTo"  index="assigned" title="Assigned To"  sortable="false"/>
</sjg:grid>

I have pojo's:

Issue.java

public class Issue implements Serializable
{
private Integer issue_id;
private String  issue_description;
private Date issue_raised_date;

getters and setters

another pojo is

Issue_Tracker.java

public class Issue_Tracker implements Serializable
{  
     private Integer issue_id;
     private String assignedTo;

and My Dao is as follows to show the list of Issues in jqgrid

public List<Issue> showHelpDeskIssues(DetachedCriteria dc, int from, int size)
{

    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
     try
      {

        Criteria criteria = dc.getExecutableCriteria(session);
        criteria.setFirstResult(from);
        criteria.setMaxResults(size);
        criteria.add(Restrictions.eq("status","Escalate To"));

        return criteria.list();
      }
      catch (HibernateException e)
      {
        e.printStackTrace();
        throw e;
      }
}
Aleksandr M
  • 23,647
  • 12
  • 63
  • 129
arvin_codeHunk
  • 2,122
  • 8
  • 29
  • 46

2 Answers2

0

You may create a set for anotheranother pojo in a pojo like this

public class Issue implements Serializable
{
private Integer issue_id;
private String  issue_description;
private Date issue_raised_date;
private Set<Issue_Tracker> issue_Tracker;

public Set<Issue_Tracker> getIssue_Tracker() {
  return issue_Tracker;
}
public void setIssue_Tracker(Set<Issue_Tracker> issue_Tracker) {
  this.sidUserSites = issue_Tracker;
 }
}

now u can access Issue_Tracker pojo through the Issue pojo. you need to use the join query

muthu
  • 4,885
  • 2
  • 29
  • 40
  • thanks again muthu ,but how to join ,because I am using criteria with restriction , otherwise i have to use create query. – arvin_codeHunk Jan 08 '13 at 10:26
  • welcome arvin please refer this http://stackoverflow.com/questions/11334743/hibernate-query-criteria-for-join-between-3-tables – muthu Jan 08 '13 at 10:40
0

U can Make a view in DB with combination columns of two tables.Create PoJo and Mapping class for that view and execute with ease!

Mathu
  • 1