I use JPA and Hibernate for my project. I have two classes with the same names , but in different packages . It:
@Entity(name = "X_USER") @Table(name = "X_USER") public class User {
and
@Entity @Table(name="Y_USER") public class User {
I created a search query using .getSimpleName() , but this did not work because their simple name is the same. I changed it to .getName() .
However, it still confuses which User to return to.
EDIT:
I have:
SELECT_BY_PROPERTY_QUERY = "SELECT p FROM :CLASS: p WHERE p.:PROPNAME:=?";
and I that:
SELECT_BY_PROPERTY_QUERY.replaceFirst(":CLASS:", clazz.getName()).replaceFirst(":PROPNAME:", propertyName);
and when I debug it, it does something like:
Select p from User p Where p.name=?
It is still User and does not include package information and returns the wrong User class to me.
source share