Hibernate运行时出现错误Column 'clazz_' not found
本人新手,正在学习spring mvc框架,在工程中出现错误,求高手指导!
错误提示:
严重: Servlet.service() for servlet [springServlet] in context with path [/rename] threw exception [Request processing failed; nested exception is
org.springframework.dao.InvalidDataAccessResourceUsageException: Column 'clazz_' not found.; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: Column 'clazz_' not found.] with root cause
java.sql.SQLException: Column 'clazz_' not found.
at
com.mysql.jdbc.SQLError.create
SQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1093)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2734)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy41.getInt(Unknown Source)
at org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$2.doExtract(IntegerTypeDescriptor.java:66)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65)
......
出现错误的代码如下:
User.java:(其他Entity文件继承了该文件)
@Entity
@Table(name="user")
@Inheritance(strategy=InheritanceType.JOINED)
public class User {
@Id
@GenericGenerator(name="generator", strategy="increment")
@GeneratedValue(generator="generator")
private int id;
@Column(name="email", unique=true, nullable=false)
private String email;
@Column(name="pwd", unique=false, nullable=false)
private String pwd;
//......省略其他属性和getter与setter
}
UserDao.java:
public interface UserDao extends JpaRepository<User, Long> {
@Query(value="select * from user where email = ?1 and pwd = ?2", nativeQuery=true)
public User findByEmailAndPwd(String email, String pwd);
}
UserService.java:
@Transactional
@Service("userService")
public class UserService {
@Autowired private UserDao userDao;
public int verify(String email, String pwd){
User user = userDao.findByEmailAndPwd(email, pwd);
if(user == null)&nbs