早教吧作业答案频道 -->其他-->
高分求教……org.hibernate.hql.ast.QuerySyntaxException:Userisnotmapped[fromUser]org.springframework.orm.hibernate3.HibernateQueryException:Userisnotmapped[fromUser];nestedexceptionisorg.hibernate.hql.ast.QuerySyntaxException:User
题目详情
高分求教……org.hibernate.hql.ast.QuerySyntaxException:User is not mapped [from User]
org.springframework.orm.hibernate3.HibernateQueryException:User is not mapped [from User]; nested exception is org.hibernate.hql.ast.QuerySyntaxException:User is not mapped [from User]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)
com.test.model.UserAction.execute(UserAction.java:54)
……
beans.xml中是:
com.test.model
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
struts.xml如下:
/success.jsp
/fail.jsp
……
.class类如下:
public String execute() throws Exception {
if(password.equals(password2)){
User user = new User();
user.setUsername(username);
user.setPassword(password);
hibernateTemplate.save(user);
return hibernateTemplate.find("from User").size()>0?"success":"fail";
}
return "fail";
}
不是我想写那么多,实在是没有办法了,第一次用struts2\hibernate\spring整合后出现的这个问题,我一整天了都没得解决,hibernateTemplate.save()可以,但hibernateTemplate.find()就不得了,把我的分拿去吧
org.springframework.orm.hibernate3.HibernateQueryException:User is not mapped [from User]; nested exception is org.hibernate.hql.ast.QuerySyntaxException:User is not mapped [from User]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)
com.test.model.UserAction.execute(UserAction.java:54)
……
beans.xml中是:
com.test.model
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
struts.xml如下:
/success.jsp
/fail.jsp
……
.class类如下:
public String execute() throws Exception {
if(password.equals(password2)){
User user = new User();
user.setUsername(username);
user.setPassword(password);
hibernateTemplate.save(user);
return hibernateTemplate.find("from User").size()>0?"success":"fail";
}
return "fail";
}
不是我想写那么多,实在是没有办法了,第一次用struts2\hibernate\spring整合后出现的这个问题,我一整天了都没得解决,hibernateTemplate.save()可以,但hibernateTemplate.find()就不得了,把我的分拿去吧
▼优质解答
答案和解析
com.test.model
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
com.test.model
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
看了 高分求教……org.hibe...的网友还看了以下:
高分求教……org.hibernate.hql.ast.QuerySyntaxException: 2020-04-26 …
Hibernate中find方法HQL语句and和or的混合使用我想写一个HQL语句查询使用,就是 2020-05-13 …
英语题,速速速速速速( ) 16. Some animals, like ____ cat, __ 2020-05-16 …
NUMERIC(6,2),我要把这个写到hibernate的映射试题对象的xml里.在xml里给这 2020-05-20 …
● 以下可以完成对象-关系映射的工具是 (63) 。 (63)A. Hibernate B. Spr 2020-05-26 …
()是Hibernate持久化操作的基础,提供了众多持久化方法,如save、update、delet 2020-05-26 …
在三层结构中,Hibernate承担的任务是()。 2020-05-26 …
如果要实现Hibernate删除一个对象时,同时级联删除与其相关联的其他对象,cascade属性的值 2020-05-26 …
元素有一个cascade属性,如果希望Hibernate级联保存集合中的对象,casecade属性应 2020-05-31 …
robots.txt中的问号有什么作用?.查看,发现有很多问号,这个问号是干么地.Disallow 2020-07-26 …