Users are not mapped issues in Hibernate (GO)

Source: Internet
Author: User

try using hibernate to build a Web project for yourself tonight, and then go for a simple login.
This error is always reported when doing query operations through Hibernate:
Users are not mapped.

So to check the next mapping, found no problem ah, repeated verification results are the same error.
User.hbm.xml:
<class name= "Com.lian.bean.User" table= "Users" >
Hibernate.cfg.xml:
<mapping resource= "Com/lian/bean/user.hbm.xml"/>
On the internet to find a lot, but still do not give force, we did not mention some constructive solutions, basically said configuration has a problem.
But I feel like this is a problem:
String sql = "Select U.password fromUsersu where u.username= ' "+user.getusername () +" ' ";
After a lot of tangled and patient looking for information, found:
OriginallyThe table name in the HQL statement should be the class name of the ORM map, so it should be changed to:
String sql = "Select U.password fromUseru where u.username= ' "+user.getusername () +" ' ";

hahaha, this gives all the people!!! of similar problems in the process of beginners hibernate

Users are not mapped issues in Hibernate (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.