package springdao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Data access object (DAO) for domain model class Bbsuser.
*
* @see springdao.Bbsuser
* @author MyEclipse Persistence Tools
*/
public class BbsuserDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(BbsuserDAO.class);
// property constants
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String AGE = "age";
protected void initDao() {
// do nothing
}
public void save(Bbsuser transientInstance) {
log.debug("saving Bbsuser instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Bbsuser persistentInstance) {
log.debug("deleting Bbsuser instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Bbsuser findById(java.lang.Integer id) {
log.debug("getting Bbsuser instance with id: " + id);
try {
Bbsuser instance = (Bbsuser) getHibernateTemplate().get(
"springdao.Bbsuser", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Bbsuser instance) {
log.debug("finding Bbsuser instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
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 Bbsuser instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Bbsuser as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByUsername(Object username) {
return findByProperty(USERNAME, username);
}
public List findByPassword(Object password) {
return findByProperty(PASSWORD, password);
}
public List findByAge(Object age) {
return findByProperty(AGE, age);
}
public List findAll() {
log.debug("finding all Bbsuser instances");
try {
String queryString = "from Bbsuser";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Bbsuser merge(Bbsuser detachedInstance) {
log.debug("merging Bbsuser instance");
try {
Bbsuser result = (Bbsuser) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Bbsuser instance) {
log.debug("attaching dirty Bbsuser instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Bbsuser instance) {
log.debug("attaching clean Bbsuser instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static BbsuserDAO getFromApplicationContext(ApplicationContext ctx) {
return (BbsuserDAO) ctx.getBean("BbsuserDAO");
}
}