当前位置: 代码迷 >> Java Web开发 >> 看一下一个添加用户中出现的有关问题
  详细解决方案

看一下一个添加用户中出现的有关问题

热度:92   发布时间:2016-04-16 22:10:57.0
看一下一个添加用户中出现的问题。
本帖最后由 u010499298 于 2014-07-05 17:47:42 编辑
我在mysql中定义的表示这样的:
然后在user.hbm,xml的文件中是这样写的
<?xml version='1.0' encoding='UTF-8'?>  
<!DOCTYPE hibernate-mapping PUBLIC  
              "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  
              "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  
    <hibernate-mapping>  
        <class name="org.zbq.bean.UserT" table="user_t">  
            <id name="userId" type="integer">  
            <column name="user_id"></column>
          <generator class="native"></generator>
            </id>  
            <property name="userName" type="string">
<column name="user_name"></column>
</property>
<property name="userPassword" type="string">
<column name="user_password"></column>
</property>
          </class>  
    </hibernate-mapping>  

添加页面只有添加用户名和密码,
   <s:textfield name="user.userName" label="userName"></s:textfield>  
            <s:textfield name="user.userPassword" label="userPassword"></s:textfield> 

我想问一下,这样的话是不是userId就会自己自动生成?
但是当我输入用户名和密码的时候为什么会提示这样的错误呢?
org.springframework.orm.hibernate3.HibernateQueryException: User is not mapped [from User u order by u.id asc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User u order by u.id asc]


------解决方案--------------------
<id name="userId" type="integer">  // 映射中用 userId 
from User u order by u.id asc           // 查询中用u.id 
把查询中的u.id 改一下吧 改为 u.userId 试试看 
  相关解决方案