?? lmdaohibernate.java
字號:
package com.relationinfo.dao.hibernate;import java.util.List;import com.relationinfo.model.Lm;import com.relationinfo.dao.LmDAO;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 LmDAOHibernate extends BaseDAOHibernate implements LmDAO { /** * @see com.relationinfo.dao.LmDAO#getLms(com.relationinfo.model.Lm) */ public List getLms(final Lm lm) { if (lm == null) { return getHibernateTemplate().find("from Lm"); } else { // filter on properties set in the lm HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Example ex = Example.create(lm).ignoreCase().enableLike(MatchMode.ANYWHERE); return session.createCriteria(Lm.class).add(ex).list(); } }; return (List) getHibernateTemplate().execute(callback); } } /** * @see com.relationinfo.dao.LmDAO#getLm(String lmbm) */ public Lm getLm(final String lmbm) { Lm lm = (Lm) getHibernateTemplate().get(Lm.class, lmbm); if (lm == null) { log.warn("uh oh, lm with lmbm '" + lmbm + "' not found..."); throw new ObjectRetrievalFailureException(Lm.class, lmbm); } return lm; } /** * @see com.relationinfo.dao.LmDAO#saveLm(Lm lm) */ public void saveLm(final Lm lm) { getHibernateTemplate().saveOrUpdate(lm); } /** * @see com.relationinfo.dao.LmDAO#removeLm(String lmbm) */ public void removeLm(final String lmbm) { getHibernateTemplate().delete(getLm(lmbm)); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -