I have three entites like this:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TYPE")
public abstract class A
{
// fields, getters, setters
}
@Entity
@DiscriminatorValue("B")
public class B extends A
{
// fields, getters, setters
}
@Entity
@DiscriminatorValue("C")
public class C extends A
{
// fields, getters, setters
}
I also have a repository like this:
@Repository
public interface ADao extends JpaRepository<A, Long>, JpaSpecificationExecutor<A>
{
}
On this repository, I have a method
List<A> findAll(Specification<A> s)
which is defined in JpaSpecificationExecutor.
My question is: how can I make a request using a specification on a field declared solely in B ?
Thanks in advance, Jerome
create a
@Repository public interface BDao extends ADao<B>{}
and
public interface ADao extends JpaRepository<T extends A, Long>, JpaSpecificationExecutor<A>
and then inject BDao to query B types
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With