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