package hibr; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.LockMode; import org.hibernate.Query; import org.hibernate.criterion.Example; /** * Data access object (DAO) for domain model class CarInfo. * @see hibr.CarInfo * @author MyEclipse - Hibernate Tools */ public class CarInfoDAO extends BaseHibernateDAO { private static final Log log = LogFactory.getLog(CarInfoDAO.class); //property constants public static final String CAR_TYPE = "carType"; public static final String PONDERANCE = "ponderance"; public static final String PRICE = "price"; public boolean save(CarInfo transientInstance) { log.debug("saving CarInfo instance"); try { getSession().save(transientInstance); log.debug("save successful"); return true; } catch (RuntimeException re) { log.error("save failed", re); return false; } } public void delete(CarInfo persistentInstance) { log.debug("deleting CarInfo instance"); try { getSession().delete(persistentInstance); log.debug("delete successful"); } catch (RuntimeException re) { log.error("delete failed", re); throw re; } } public CarInfo findById( java.lang.String id) { log.debug("getting CarInfo instance with id: " + id); try { CarInfo instance = (CarInfo) getSession() .get("hibr.CarInfo", id); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } public List findByCarId(String id) { String carid="from CarInfo where Carid='"+id+"'"; Query q=getSession().createQuery(carid); return q.list(); } public List findByExample(CarInfo instance) { log.debug("finding CarInfo instance by example"); try { List results = getSession() .createCriteria("hibr.CarInfo") .add(Example.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 CarInfo instance with property: " + propertyName + ", value: " + value); try { String queryString = "from CarInfo 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 findByCarType(Object carType) { return findByProperty(CAR_TYPE, carType); } public List findByPonderance(Object ponderance) { return findByProperty(PONDERANCE, ponderance); } public List findByPrice(Object price) { return findByProperty(PRICE, price); } public CarInfo merge(CarInfo detachedInstance) { log.debug("merging CarInfo instance"); try { CarInfo result = (CarInfo) getSession() .merge(detachedInstance); log.debug("merge successful"); return result; } catch (RuntimeException re) { log.error("merge failed", re); throw re; } } public void attachDirty(CarInfo instance) { log.debug("attaching dirty CarInfo instance"); try { getSession().saveOrUpdate(instance); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } public void attachClean(CarInfo instance) { log.debug("attaching clean CarInfo instance"); try { getSession().lock(instance, LockMode.NONE); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } }
最近下载更多
微信网友_6403021990891520 LV1
2023年3月24日
17330686178 LV1
2022年12月1日
地上有草 LV12
2022年5月11日
Jeasonchan898 LV2
2022年4月26日
ForestStone LV2
2022年4月25日
isfrand LV4
2022年4月18日
1532593037 LV8
2022年3月31日
and123456 LV11
2022年2月7日
七七qqqq25055 LV1
2021年11月23日
zww1223 LV4
2021年9月1日