用ssh 两个主外键表查询问题
--表一create table bug_project( id number, name varchar(100) not null, constraint PK_project primary key(id));表二create table bug_detail( id number, projectId number not null, severity number not null, tiele varchar(100) not null, reportuser varchar(50) not null, createdate date not null, constraint PK_detail primary key(id), constraint FK_project foreign key(projectId) references bug_project(id));
//映射public class BugDetail implements java.io.Serializable { // Fields private Long id; private BugProject bugProject; private Long severity; private String tiele; private String reportuser; private Date createdate;<s:iterator value="all"><tr> td><s:property value="id" /></td> <td><s:property value="tiele" /></td> <td><s:property value="reportuser" /></td> <td><s:property value="createdate" /></td></tr></s:iterator>
import java.util.ArrayList;import com.opensymphony.xwork2.ActionSupport;public class BugAction extends ActionSupport{ private IBugBiz iBugBiz; private ArrayList<BugDetail> detailList = new ArrayList<BugDetail>(); public void setDetailList(ArrayList<BugDetail> detailList) { this.detailList = detailList; } public ArrayList<BugDetail> getDetailList() { return detailList; } public String select() { detailList = iBugBiz.findAll(); return "selectAll"; } }
[解决办法]
你的查询语句要使用联合查询,才能查到另一个表,你使用的是ssh框架,通过h的映射,就可以知道获得另一个表的id ,但获得不到别的信息
[解决办法]
你的查询语句要使用联合查询,才能查到另一个表,你使用的是ssh框架,通过h的映射,就可以直接获得另一个表的id ,但获得不到别的信息