日期:2014-05-18 浏览次数:20714 次
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; //是否过期<