Org. hibernate. mappingexception: unknown entity: COM. PKMs. entity. User

Source: Internet
Author: User

 

 
1 error Org. hibernate. mappingexception: unknown entity: COM. PKMs. entity. userat Org. hibernate. impl. sessionfactoryimpl. getentitypersister (sessionfactoryimpl. java: 628) at Org. hibernate. event. def. defaultloadeventlistener. onload (defaultloadeventlistener. java: 91) at Org. hibernate. impl. sessionimpl. fireload (sessionimpl. java: 906) at Org. hibernate. impl. sessionimpl. get (sessionimpl. java: 843) at Org. hibernate. impl. sessionimpl. get (sessionimpl. java: 836) at com. core. hibernate. hibernatedao. get (hibernatedao. java: 39) at com. core. hibernate. hibernatedao. get (hibernatedao. java: 47) at com. core. hibernate. hibernatedao $ fastclassbycglib $ b72f665e. invoke (<generated>) at net. SF. cglib. proxy. methodproxy. invoke (methodproxy. java: 149)

2. Cause
1) cocould not load an entity: [COM. kaisir. server. VO. User #1]
2) There is a syntax error near the keyword 'user.

Because the hibernate-related parts are generated by myeclipse, theoretically there will be no errors from the ing file to VO. Later, after checking, the cause of the error is that "user" is the keyword of SQL Server. Hibernate is not smart enough to add "[]" to the keyword to indicate differentiation.

 

3. Solution

<Bean id ="Sessionfactory"

Class ="Org. springframework. Orm. hibernate3.annotation. annotationsessionfactorybean">

 

Add

<Property name ="Packagestoscan"Value ="Com. PKMs .*"/>

 

 

@ Table (name = "users", schema = "DBO", catalog = "PKMs ")

 

 

Finally, change the database name to t_user.

It turns out to be caused by a conflict with the database keyword. Khan.

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.