67,549
社区成员




public List<PubRequest> getRequest(String userName) {
Session session = sessionFactory.openSession();
// @SuppressWarnings("unchecked") 嘛意思
List<PubRequest> pubrequests = session
.createQuery("from PubRequest as p where p.pubuser.userName = ? and p.allowText ='同意' ")
.setString(0, userName)
.list();
for(PubRequest pubrequest:pubrequests){
System.out.println(pubrequest.getAllowText()+"============================");
}
for(PubRequest pubrequest:pubrequests){
System.out.println(pubrequest.getPubuser().getTrueName()+"============================");
System.out.println(pubrequest.getPubtest().getTestName()+"============================");
}
session.close();
return pubrequests;
}
}
package com.niit.bean;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import org.hibernate.annotations.Proxy;
/**
*
* 考试信息表
*/
@Entity
public class PubTest implements Serializable{
@Id
@GeneratedValue
private int testId; //考试id
private String testName; //考试名
@Column(columnDefinition="timestamp")
private Date startTime; //开始时间
@Column(columnDefinition="timestamp")
private Date endTime; //结束时间
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="tacticsId") //策略
private PubTactics pubtactics;
private String isTimeOut; //是否过期
@OneToMany(mappedBy="pubtest",fetch=FetchType.LAZY)
private Set<PubExamQuestion> pubexamquestions; //考试对应表(用来两表关联)
@OneToMany(mappedBy="pubtest",fetch=FetchType.LAZY)
private Set<TestPersonList> testPersonLists; //考试结果表
@OneToMany(mappedBy="pubtest",fetch=FetchType.LAZY)
private Set<PubRequest> pubRequests; //考试请求表
@OneToOne(mappedBy="pubtest",fetch=FetchType.LAZY)
private PubTestList pubtestlist; //考试结果表(总)
/*方法略*/
}
package com.niit.bean;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
/**
* 考生信息表
*/
@Entity
public class PubUser implements Serializable {
@Id
@GeneratedValue
private int userId; // 考生ID
@Column(unique = true)
private String userName; // 登录用户名
@Column(nullable = false)
private String userPassword; // 登陆密码
private String examId; // 准考证号
private String userSex; // 考生性别
private String cardType; // 证件类型
private String cardNum; // 证件号码
private String userPhone; // 联系电话
private String communiType; // 联系方式
private String communiNum; // 即时通讯号
private String userAddress; // 考生地址
private String trueName; // 考生真实姓名
private String userSchool; // 考生学校
private String userEmail; // 考生邮箱
private String userPost; // 考生邮编
private String userClass; // 考生所在班级
@OneToMany(mappedBy = "pubuser", fetch = FetchType.LAZY)
private Set<TestPersonList> testPersonLists; // 考试结果表
@OneToMany(mappedBy = "pubuser", fetch = FetchType.LAZY)
private Set<PubRequest> pubrequests; // 考试申请
/*方法略*/
}
package com.niit.bean;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
/**
*考试请求表
*/
@Entity
public class PubRequest implements Serializable {
@Id
@GeneratedValue
private int requestId; //请求ID
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="testId",nullable=false)
private PubTest pubtest; //考试信息
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="userId",nullable=false)
private PubUser pubuser; //考生ID
private String allowText; //是否同意
private Date RequestTime; //申请日期
/*方法略*/