正确写法:
由于对该类不理解或者复制时容易出这样的错误
17. 错误十七
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'localSessionFactoryBean' defined in class path resource [spring-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
Caused by: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
这里根据提示说错误的原因是当数据库不能连接的时候,需要配置hibernate.dialect'就是hibernate配置的方言,原因出在驱动类的配置,比如:properties文件中的:hibernate.driverClassName=oracle.jdbc.driver.OracleDriver
这里如果写错了就会出现不能连接的情况,驱动的名字一定要正确,配置文件中的其他属性也一定要正确,据我本人测试如果在改配置文件中直接写的driverClassName=oracle.jdbc.driver.OracleDriver
在spring配置文件这样取值时:
18. 错误十八
java.lang.IllegalArgumentException: node to traverse cannot be null!
解决方法:通常此类错误都是由于HQL语句写的不正确,例如from写成了form,或者set A = 1 and B = 2,其中set不同字段用逗号","分离而不是用and.总之仔细检查HQL语句,看看有没有语法错误即可.