Java /JPA | Query with specified inherited type

后端 未结 4 1842
野的像风
野的像风 2020-12-10 13:23

I am building a query on a generic table \"Sample\" and I have several types which inherit from this table \"SampleOne\", \"SampleTwo\". I require a query like :

         


        
4条回答
  •  遥遥无期
    2020-12-10 14:06

    Do this in your repository

    @Query("SELECT p FROM BaseUserEntity p where p.class=:discriminatorValue")
        public List findByDiscriminatorValue(@Param("discriminatorValue") String discriminatorValue);
    

    Where BaseUserEntity is your parent entity

提交回复
热议问题