数据库有数据,但就是查询不到,用的sqlserver2005,
代码如下:public T queryEntity(T t,Serializable id) throws Exception{
try{
return (T) this.getHibernateTemplate().load(Class.forName(t.getClass().getName()), id);
}catch(RuntimeException e){
logger.error("查询实体异常"+t.getClass().getName(),e);
throw e;
}
}
测试类:
public class Test {
public static void main(String[] args) {
Function function =new Function();
AuthorityDaoImpl authorityDaoImpl=new AuthorityDaoImpl();
try {
authorityDaoImpl.queryAllEntity(function);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace(); }
}
}报如下错误:
log4j:WARN No appenders could be found for logger (com.hr.platform.dao.BaseHibernateDao).
log4j:WARN Please initialize the log4j system properly.
java.lang.NullPointerException
at com.hr.platform.dao.BaseHibernateDao.queryAllEntity(BaseHibernateDao.java:63)
at com.hr.authority.test.Test.main(Test.java:11)
代码如下:public T queryEntity(T t,Serializable id) throws Exception{
try{
return (T) this.getHibernateTemplate().load(Class.forName(t.getClass().getName()), id);
}catch(RuntimeException e){
logger.error("查询实体异常"+t.getClass().getName(),e);
throw e;
}
}
测试类:
public class Test {
public static void main(String[] args) {
Function function =new Function();
AuthorityDaoImpl authorityDaoImpl=new AuthorityDaoImpl();
try {
authorityDaoImpl.queryAllEntity(function);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace(); }
}
}报如下错误:
log4j:WARN No appenders could be found for logger (com.hr.platform.dao.BaseHibernateDao).
log4j:WARN Please initialize the log4j system properly.
java.lang.NullPointerException
at com.hr.platform.dao.BaseHibernateDao.queryAllEntity(BaseHibernateDao.java:63)
at com.hr.authority.test.Test.main(Test.java:11)
解决方案 »
- 房贷计算器是怎么实现的啊
- 请教jsp如何调用js中的数据
- validation 不验证。
- 关于sql语句联合查询时碰到空值时的问题
- 求助:test.jsp?val=变量,在test.jsp中获取val值的问题(在线等)
- 一个奇怪的问题,不知道大家见过没有?
- 关于web认证的问题!
- dreamweaver中连接Sql server2000的数据库出现了class not found错误,请问是什么错误
- 200分求资料
- 当使用http://localhost:8080/myWeb/login.do?时,为什么javascript:load ();无效?
- jsp和数据库的一点小问题
- 邮件发送功能的方案设计
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 配置传播事务特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 对修改数据的方法添加的事务 -->
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<!-- 对查询的方法添加的事务,添加read-only属性为true提升效率 -->
<tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="load*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethod"
expression="execution (* com.hr.*.dao.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
</aop:config>
<aop:config>
<aop:pointcut id="platallManagerMethod"
expression="execution (* com.hr.*.dao.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="platallManagerMethod" />
</aop:config>
<aop:aspectj-autoproxy proxy-target-class="true" />
public static void main(String[] args) {
Function function =new Function();
AuthorityDaoImpl authorityDaoImpl=new AuthorityDaoImpl();
try {
authorityDaoImpl.queryAllEntity(function);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();}
}
}AuthorityDaoImpl authorityDaoImpl=new AuthorityDaoImpl();没住人啊 你直接new出来的 不是通过spring得到的 spring懒得管你