帮我解释下这段代码
publicclassTAdminDAOextendsHibernateDaoSupport{privatestaticfinalLoglog=LogFactory.ge...
public class TAdminDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(TAdminDAO.class);
// property constants
public static final String USER_NAME = "userName";
public static final String USER_PW = "userPw";
protected void initDao() {
// do nothing
}
public void save(TAdmin transientInstance) {
log.debug("saving TAdmin instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(TAdmin persistentInstance) {
log.debug("deleting TAdmin instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public TAdmin findById(java.lang.Integer id) {
log.debug("getting TAdmin instance with id: " + id);
try {
TAdmin instance = (TAdmin) getHibernateTemplate().get(
"com.model.TAdmin", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
}
public List findByExample(TAdmin instance) {
log.debug("finding TAdmin 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 TAdmin instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from TAdmin as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
} 展开
private static final Log log = LogFactory.getLog(TAdminDAO.class);
// property constants
public static final String USER_NAME = "userName";
public static final String USER_PW = "userPw";
protected void initDao() {
// do nothing
}
public void save(TAdmin transientInstance) {
log.debug("saving TAdmin instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(TAdmin persistentInstance) {
log.debug("deleting TAdmin instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public TAdmin findById(java.lang.Integer id) {
log.debug("getting TAdmin instance with id: " + id);
try {
TAdmin instance = (TAdmin) getHibernateTemplate().get(
"com.model.TAdmin", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
}
public List findByExample(TAdmin instance) {
log.debug("finding TAdmin 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 TAdmin instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from TAdmin as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
} 展开
1个回答
展开全部
这段代码其实就是三个方法 一个保存,一个删除, 还有一个按ID查找,首先的话先声明两个变量 姓名和 密码
第一个保存方法 调用Hibernate 中的getHibernateTemplate().sava()方法 在括号中传入需要保存的参数,然后检测这段代码,如果成功显示save successful 失败的话抛出异常save failed
以此类推一下方法都是通过Hibernate 的 getHibernateTemplate()中的方法来实现的
第一个保存方法 调用Hibernate 中的getHibernateTemplate().sava()方法 在括号中传入需要保存的参数,然后检测这段代码,如果成功显示save successful 失败的话抛出异常save failed
以此类推一下方法都是通过Hibernate 的 getHibernateTemplate()中的方法来实现的
上海巴鲁图工程机械科技有限公司_
2022-05-15 广告
2022-05-15 广告
光电编码器,是一种通过光电转换将输出轴上的机械几何位移量转换成脉冲或数字量的传感器。光电编码器每转输出60(我们用老板没有说)个脉冲,五线制。其中两根为电源线,三根为脉冲线(A相、B相、Z)。电源的工作电压为 (+5~+24V)直流电源。光...
点击进入详情页
本回答由上海巴鲁图工程机械科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询