myUser is not mapped
数据库中的表 myUser要在哪些文件里配置啊??
User.hbm.xml 中配置不就OK了吗,还有哪里需要配置??
<hibernate-mapping>
<class name="com.test.Hibernate.User" table="myUser">
<id name="id" type="integer">
<column name="ID" />
<generator class="native"></generator>
</id>
<property name="username" type="string">
<column name="USERNAME" length="50" not-null="true" />
</property>
<property name="password" type="string">
<column name="PASSWORD" length="50" not-null="true" />
</property>
</class>
</hibernate-mapping>

解决方案 »

  1.   

    HQL语句要这样:from User u where u.username=? and u.password=?
      

  2.   

    同意changjz,HQL语句是面向对象的,所以根本就不知道有myUser表的存在,只能对对象进行查找from User u where u.username=? and u.password=?
      

  3.   

    谢谢上面的回答,原来的错误没有了,但是出现了新的问题:
    javax.servlet.ServletException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Cannot create PoolableConnectionFactory (Communications link failure due to underlying 
    exception: java.net.SocketException: java.net.ConnectException: Connection refused: connect
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)我把数据库改成了SQLserver的,applicationContext.xml里的配置都改了,怎么还会去连接MySQL呢
      

  4.   

    applicationContext.xml 作了如下修改:
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName">
    <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
    </property>
    <property name="url">
    <value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=BBS</value>
    </property>
    <property name="username">
    <value>sa</value>
    </property>
    <property name="password">
    <value>sa</value>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    请问还有什么其他地方要改的吗??
      

  5.   

    SSH为什么这么麻烦啊,一个login得弄N多配置和代码
    还是没搞定,继续等
      

  6.   

    你是不是在hibernate.hbm.xml中也配置了数据源?