这段代码什么意思,能否详细解释下

public class BookInfoDAO extends BaseHibernateDAO {
private static final Logger log = LoggerFactory
.getLogger(BookInfoDAO.class);

public void save(BookInfo transientInstance) {
log.debug("saving BookInfo instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}

public void delete(BookInfo persistentInstance) {
log.debug("deleting BookInfo instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}

public BookInfo findById(java.lang.Integer id) {
log.debug("getting BookInfo instance with id: " + id);
try {
BookInfo instance = (BookInfo) getSession().get(
"hiber.domain.BookInfo", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}

public List<BookInfo> findByExample(BookInfo instance) {
log.debug("finding BookInfo instance by example");
try {
List<BookInfo> results = (List<BookInfo>) getSession()
.createCriteria("hiber.domain.BookInfo").add(
create(instance)).list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}

public List findByProperty(String propertyName, Object value) {
log.debug("finding BookInfo instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from BookInfo as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}

public List findAll() {
log.debug("finding all BookInfo instances");
try {
String queryString = "from BookInfo";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}

public BookInfo merge(BookInfo detachedInstance) {
log.debug("merging BookInfo instance");
try {
BookInfo result = (BookInfo) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}

public void attachDirty(BookInfo instance) {
log.debug("attaching dirty BookInfo instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}

第1个回答  2011-06-17
5分详细解释不太划算。这个功能就是分拆表单,从里面分离出需要的数据。
你找一个抓包工具,上传个文件,抓一下数据包,对照着看你就明白为什么这么分拆了。
第2个回答  2011-06-16
基于HIBERNATE的DAO层中的一个类,写了几个方法本回答被提问者采纳
相似回答