Resolves a mapping failure caused by physical and entity in different packages in hibernate

Source: Internet
Author: User

The error code is as follows:

caused by:org.hibernate.DuplicateMappingException:duplicateImport: Engin refers to both Two.entity.Engin and Allview.entity.Engin (TryUsing auto-Import= "false") at Org.hibernate.cfg.configuration$mappingsimpl.addimport (Configuration.java:2892) at Org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues (Hbmbinder.java:681) at Org.hibernate.cfg.HbmBinder.bindClass (Hbmbinder.java:595) at Org.hibernate.cfg.HbmBinder.bindRootClass (Hbmbinder.java:325) at Org.hibernate.cfg.HbmBinder.bindRoot (Hbmbinder.java:178) at Org.hibernate.cfg.configuration$metadatasourcequeue.processhbmxml (Configuration.java:3816)    ... More

The cause of this exception may be:

In your project, there are two engin classes, such as: Two.entity.Engin and Allview.entity.Engin, although located in different packages, but there will be duplicate import exception, the solution is as follows:

    • A simpler way to change one of the class names.
    • The second solution, the mapping file of one of the classes corresponding to the engin.hbm.xml,so change, you must pay attention, in writing HQL statements, such as "Two.entity.Engin", must add the full package name, Because you set the auto-import= "false".

Resolves a mapping failure caused by physical and entity in different packages in hibernate

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.