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