Using Hibernate and JPA you cannot have two classes with the same name (on different packages) mapped. This raise an error at runtime:
Caused by: org.hibernate.DuplicateMappingException: duplicate import: MyClass refers to both com.intre.MyClass and com.dummy.MyClass (try using auto-import=”false”)
To solve this issue on the Entity annotation of com.intre.MyClass and com.dummy.Class add the property name.
package com.intre;
@Entity(name = “com.intre.myclass”)
@Table(name = “MyClass”)
public class MyClass …
package com.dummy;
@Entity(name = “com.dummy.myclass”)
@Table(name = “MyClass”)
public class MyClass …
Use in the 2 entity mapping xml file can also solve the issue.
Hi Marcus, yes it’s true but if you want to use just annotation I found only this way. Do you have other solutions using annotations? Should be great! 🙂