// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: BooksDAO.java
package com.yyzy.dao;
import com.yyzy.press.Books;
import com.yyzy.press.PageList;
import java.util.List;
import org.hibernate.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class BooksDAO extends HibernateDaoSupport
{
private static final Logger log = LoggerFactory.getLogger("com/yyzy/dao/BooksDAO");
public static final String BOOK_NO = "bookNo";
public static final String ISBN = "isbn";
public static final String SUBJECT_NAME = "subjectName";
public static final String SUBTITLE_NAME = "subtitleName";
public static final String STAND_NAME = "standName";
public static final String DUTY = "duty";
public static final String OTHER_DUTY = "otherDuty";
public static final String FRAC_NAME = "fracName";
public static final String FRAC = "frac";
public static final String BOOKTYPE_NO = "booktypeNo";
public static final String BOOKTYPE_NAME = "booktypeName";
public static final String PUBLISH = "publish";
public static final String PUBLISH_DATE = "publishDate";
public static final String PUBLISH_ADDRESS = "publishAddress";
public static final String PAGE_NO = "pageNo";
public static final String PRICE = "price";
public static final String COUNT = "count";
public static final String ORDER_EDITION = "orderEdition";
public static final String DOM_TYPE = "domType";
public static final String LANGUAGE_TYPE = "languageType";
public static final String STITCH = "stitch";
public static final String OPEN_BOOK = "openBook";
public static final String VOLUME = "volume";
public static final String RELL = "rell";
public static final String AFFIX = "affix";
public static final String KEY_WORD = "keyWord";
public static final String BRIEF = "brief";
public BooksDAO()
{
}
protected void initDao()
{
}
// 图 书添加的数据
public void save(Books transientInstance)
{
log.debug("saving Books instance");
try
{
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
}
catch (RuntimeException re)
{
log.error("save failed", re);
throw re;
}
}
//通过bookno查找
public List<Books> bynameselect(String tiaoma){
try {
String sqlString="from Books where bookNo=?";
Query query=this.getSession().createQuery(sqlString);
query.setParameter(0, tiaoma);
return query.list();
} catch (RuntimeException re) {
// TODO: handle exception
throw re;
}
}
//查找圖書、價格
public List<Books> findAllsan() {
log.debug("finding all Books instances");
try {
String queryString = "from Books";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
//分页
public PageList findByPage(int pageSize, int pageNew)
{
PageList pageList = new PageList(pageSize, pageNew);
String sqlsString = "select count(*) from Books";
Query query = getSession().createQuery(sqlsString);
pageList.setRowCount(((Long)query.uniqueResult()).intValue());
sqlsString = "from Books";
Query query2 = getSession().createQuery(sqlsString);
query2.setFirstResult((pageNew - 1) * pageSize);
query2.setMaxResults(pageSize * pageNew);
pageList.setList(query2.list());
pageList.pageCountye();
return pageList;
}
public void delete(Books persistentInstance)
{
log.debug("deleting Books instance");
try
{
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
}
catch (RuntimeException re)
{
log.error("delete failed", re);
throw re;
}
}
//修改添 加 图 书的数据
public void updatexiu(String bookNo, String isbn, String subjectName, String subtitleName, Double price, String publish, String publishDate,
Integer bookId)
{
try
{
String sqlString = "update Books set bookNo=?,isbn=?,subjectName=?,subtitleName=?,price=?,publish=?,publishDate=? where bookId=?";
Query query = getSession().createQuery(sqlString);
query.setParameter(0, bookNo);
query.setParameter(1, isbn);
query.setParameter(2, subjectName);
query.setParameter(3, subtitleName);
query.setParameter(4, price);
query.setParameter(5, publish);
query.setParameter(6, publishDate);
query.setParameter(7, bookId);
query.executeUpdate();
}
catch (RuntimeException re)
{
log.error("delete failed", re);
throw re;
}
}
//通过ID查找修改数据
public List findByIdUpdateGai(Integer bookId)
{
Query query;
String sqlsString = "from Books where bookId=?";
query = getSession().createQuery(sqlsString);
query.setParameter(0, bookId);
return query.list();
}
//通过ID删除数据
public void byIDdelete(Integer bookId)
{
log.debug("deleting Books instance");
try
{
String sqlString = "delete from Books where bookId=?";
Query query = getSession().createQuery(sqlString);
query.setParameter(0, bookId);
query.executeUpdate();
}
catch (RuntimeException re)
{
log.error("delete failed", re);
throw re;
}
}
public Books findById(Integer id)
{
log.debug((new StringBuilder("getting Books instance with id: ")).append(id).toString());
Books instance = (Books)getHibernateTemplate().get("com.yyzy.press.Books", id);
return instance;
}
public List findByExample(Books instance)
{
log.debug("finding Books instance by example");
List results;
results = getHibernateTemplate().findByExample(instance);
log.debug((new StringBuilder("find by example successful, result size: ")).append(results.size()).toString());
return results;
}
public List findByProperty(String propertyName, Object value)
{
log.debug((new StringBuilder("finding Books instance with property: ")).append(propertyName).append(", value: ").append(value).toString());
String queryString = (new StringBuilder("from Books as model where model.")).append(propertyName).append("= ?").toString();
return getHibernateTemplate().find(queryString, value);
}
public List findByBookNo(Object bookNo)
{
return findByProperty("bookNo", bookNo);
}
public List findByIsbn(Object isbn)
{
return findByProperty("isbn", isbn);
}
public List findBySubjectName(Object subjectName)
{
return findByProperty("subjectName", subjectName);
}
public List findBySubtitleName(Object subtitleName)
{
return findByProperty("subtitleName", subtitleName);
}
public List findByStandName(Object standName)
{
return findByProperty("standName", standName);
}
public List findByDuty(Object duty)
{
return findByProperty("duty", duty);
}
public List findByOtherDuty(Object otherDuty)
{
return findByProperty("otherDuty", otherDuty);
}
public List findByFracName(Object fracName)
{
return findByProperty("fracName", fracName);
}
public List findByFrac(Object frac)
{
return findByProperty("frac", frac);
}
public List findByBooktypeNo(Object booktypeNo)
{
return findByProperty("booktypeNo", booktypeNo);
}
public List findByBooktypeName(Object booktypeName)
{
return findByProperty("booktypeName", booktypeName);
}
public List findByPublish(Object publish)
{
return findByProperty("publish", publish);
}
public List findByPublishDate(Object publishDate)
{
return findByProperty("publishDate", publishDate);
}
public List findByPublishAddress(Object publishAddress)
{
return findByProperty("publishAddress", publishAddress);
}
public List findByPageNo(Object pageNo)
{
return findByProperty("pageNo", pageNo);
}
public List findByPrice(Object price)
{
return findByProperty("price", price);
}
public List findByCount(Object count)
{
return findByProperty("count", count);