I have those jpa Entities
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
class AbstarctAddress {
}
@Entity
public class ConsolidationHub extends AbstarctAddress {
}
@Entity
class Transport {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "delivery_address_id")
private AbstarctAddress address;
}
when I am doing
select t from Transport t left join fetch t.address
and then instanceof check like this
t.getAddress() instanceOf ConsolidationHub it returns false
. This is because I got hibernate proxy. when I change to EAGER I don't have that problem. but I don't want to put EAGER since I have performance problems with EAGER.
Do you know how it is possible to solve this issue?
PS. I know that instanceOf check is bad practice, I just need to maintain old code in which there are lots of instanceOf checks and I cannot refactor all of them now.