📄 xxdaohibernate.java
字号:
package com.relationinfo.dao.hibernate;import java.util.List;import com.relationinfo.model.Xx;import com.relationinfo.dao.XxDAO;import org.hibernate.HibernateException;import org.hibernate.Session;import org.hibernate.criterion.Example;import org.hibernate.criterion.MatchMode;import org.springframework.orm.ObjectRetrievalFailureException;import org.springframework.orm.hibernate3.HibernateCallback;public class XxDAOHibernate extends BaseDAOHibernate implements XxDAO { /** * @see com.relationinfo.dao.XxDAO#getXxs(com.relationinfo.model.Xx) */ public List getXxs(final Xx xx) { if (xx == null) { return getHibernateTemplate().find("from Xx"); } else { // filter on properties set in the xx HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Example ex = Example.create(xx).ignoreCase().enableLike(MatchMode.ANYWHERE); return session.createCriteria(Xx.class).add(ex).list(); } }; return (List) getHibernateTemplate().execute(callback); } } /** * @see com.relationinfo.dao.XxDAO#getXx(String xxbm) */ public Xx getXx(final String xxbm) { Xx xx = (Xx) getHibernateTemplate().get(Xx.class, xxbm); if (xx == null) { log.warn("uh oh, xx with xxbm '" + xxbm + "' not found..."); throw new ObjectRetrievalFailureException(Xx.class, xxbm); } return xx; } /** * @see com.relationinfo.dao.XxDAO#saveXx(Xx xx) */ public void saveXx(final Xx xx) { getHibernateTemplate().saveOrUpdate(xx); } /** * @see com.relationinfo.dao.XxDAO#removeXx(String xxbm) */ public void removeXx(final String xxbm) { getHibernateTemplate().delete(getXx(xxbm)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -