how to show two tables data in jqgrid using struts2 - jqgrid plugin and hibernate
Asked Answered
N

2

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;
      }
}
Neither answered 8/1, 2013 at 9:8 Comment(0)
L
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

Loralorain answered 8/1, 2013 at 10:22 Comment(2)
thanks again muthu ,but how to join ,because I am using criteria with restriction , otherwise i have to use create query.Neither
welcome arvin please refer this #11335243Loralorain
C
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!

Copacetic answered 19/2, 2013 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.