📄 exampleaction.java
字号:
package hibernate;
import hibernate.iml.Bakmusic;
import hibernate.iml.BakmusicOperation;
import hibernate.iml.DBOperaion;
import hibernate.iml.Example;
import java.util.Collection;
import java.util.Date;
import net.sf.hibernate.HibernateException;
public class ExampleAction {
// Fields
private String id;
private String detail;
private String others;
private Date sysdate;
/** pagestr property */
private String pagestr;
/** page property */
private String page;
private int pageSize;
private String method;
private final String strSQLOrder = " order by sysdate desc";
public Collection getSelect(){
Collection collection = null;
String sqlString = " from Example";
sqlString += strSQLOrder;
int Page = 1;
if((page!=null)&&(!page.equals(""))&&(!page.equalsIgnoreCase("null"))){
Page = Integer.parseInt(page);
}else page = "1";
Page = (Page<1)?1:Page;
try {
DBOperaion opHandle = new DBOperaion();
opHandle.setPageSize(7);
collection = opHandle.getAll(sqlString,Page,"example.jsp?page=");
pagestr = opHandle.getPageStr();
pageSize = opHandle.getPageSize();
} catch (HibernateException e) {
e.printStackTrace();
}
return collection;
}
public Collection getFirst(){
Collection collection = null;
String sqlString = " from Example";
sqlString += strSQLOrder;
try {
DBOperaion opHandle = new DBOperaion();
opHandle.setPageSize(8);
collection = opHandle.getAll(sqlString,1,"");
} catch (HibernateException e) {
e.printStackTrace();
}
return collection;
}
public boolean delete(){
if( (id == null)||(id.equals(""))||(id.equals(" "))||(id.equals("null")) ) return false;
boolean returnCode = true;
try {
DBOperaion opHandle = new DBOperaion();
opHandle.delete(Example.class,id);
} catch (HibernateException e) {
returnCode = false;
e.printStackTrace();
}
return returnCode;
}
public boolean insert(){
boolean returnCode = true;
if(isValid()){
Example object = new Example();
object.setDetail(this.detail);
object.setOthers(this.others);
object.setSysdate(new Date());
try {
BakmusicOperation opHandle = new BakmusicOperation();
opHandle.insert(object);
} catch (HibernateException e) {
returnCode = false;
e.printStackTrace();
}
}else returnCode = false;
return returnCode;
}
private boolean isValid(){
if( (detail == null)||(detail.equals(""))||(detail.equals(" "))||(detail.equals("null")) ) return false;
if( (others == null)||(others.equals(""))||(others.equals(" "))||(others.equals("null")) ) return false;
return true;
}
// Property accessors
/**
* Returns the page.
* @return String
*/
public String getPage() {
return page;
}
/**
* Set the page.
* @param page The page to set
*/
public void setPage(String page) {
this.page = page;
}
public String getPagestr() {
return pagestr;
}
public void setPagestr(String pagestr) {
this.pagestr = pagestr;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getDetail() {
return this.detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public String getOthers() {
return this.others;
}
public void setOthers(String others) {
this.others = others;
}
public Date getSysdate() {
return this.sysdate;
}
public void setSysdate(Date sysdate) {
this.sysdate = sysdate;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -