当前位置: 代码迷 >> Java Web开发 >> 初学者问Mybatis 关联关系 如何配置
  详细解决方案

初学者问Mybatis 关联关系 如何配置

热度:2328   发布时间:2016-04-10 23:02:22.0
菜鸟问Mybatis 关联关系 怎么配置
两张表的实体类:
package model;

import java.util.HashSet;
import java.util.Set;

/**
 * Project entity. @author MyEclipse Persistence Tools
 */

public class Project implements java.io.Serializable {

// Fields

private int id;
private String projectname;
private Set workorders = new HashSet(0);

// Constructors

/** default constructor */
public Project() {
}

/** minimal constructor */
public Project(int id, String projectname) {
this.id = id;
this.projectname = projectname;
}

/** full constructor */
public Project(int id, String projectname, Set workorders) {
this.id = id;
this.projectname = projectname;
this.workorders = workorders;
}

// Property accessors

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}

public String getProjectname() {
return this.projectname;
}

public void setProjectname(String projectname) {
this.projectname = projectname;
}

public Set getWorkorders() {
return this.workorders;
}

public void setWorkorders(Set workorders) {
this.workorders = workorders;
}

}


package model;

import java.util.Date;

/**
 * Workorder entity. @author MyEclipse Persistence Tools
 */

public class Workorder implements java.io.Serializable {

// Fields

private int id;
private Project project;
private String executor;
private String description;
private int orderlevel;
private Date createdate;

// Constructors

/** default constructor */
public Workorder() {
}

/** full constructor */
public Workorder(int id, Project project, String executor,
String description, int orderlevel, Date createdate) {
this.id = id;
this.project = project;
this.executor = executor;
this.description = description;
this.orderlevel = orderlevel;
this.createdate = createdate;
}

// Property accessors

public Workorder(Project project, String executor, String description,
int orderlevel, Date createdate) {
super();
this.project = project;
this.executor = executor;
this.description = description;
this.orderlevel = orderlevel;
this.createdate = createdate;
}

public Workorder(String executor, String description, int orderlevel,
Date createdate) {
super();
this.executor = executor;
this.description = description;
this.orderlevel = orderlevel;
this.createdate = createdate;
}

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}

public Project getProject() {
return this.project;
}

public void setProject(Project project) {
this.project = project;
}

public String getExecutor() {
return this.executor;
}

public void setExecutor(String executor) {
this.executor = executor;
}

public String getDescription() {
return this.description;
}

public void setDescription(String description) {
this.description = description;
}

public int getOrderlevel() {
return this.orderlevel;
}

public void setOrderlevel(int orderlevel) {
this.orderlevel = orderlevel;
}

public Date getCreatedate() {
return this.createdate;
}

public void setCreatedate(Date createdate) {
this.createdate = createdate;
}

}

jsp页面:
<html>
  <head>
    
    <title>显示</title>
  </head>
  
  <body>
       <table width="auto" border="1">
  <tr>
    <td>员工编号</td>
    <td>项目名称</td>
    <td>执行人</td>
    <td>任务描述</td>
    <td>级别</td>
    <td>创建时间</td>
  </tr>
  相关解决方案