0

Error

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Integer] to type [@org.springframework.data.jpa.repository.Query com.entity.CombHoldingRule]

Entity Class is like below

    @Type(type = "int-array")
    @Column(
            name = "holdingrule_list",
            columnDefinition = "int[]"
    )
    private int[] holdingRuleList;//Checked

Repository :-

@Query(value="select combHoldingRuleId , " +
            "combHoldingRuleName, " +
            "jurisdictionId, " +
            "functionGroupId, " +
            "overallNettingType, " +
            "packageId ," +
            "holdingRuleList from CombHoldingRule where packageId=:packageId")
    //@Query(value=query,nativeQuery = true)
    List<CombHoldingRule> repoCHRFromPackageId(@Param("packageId") int packageId);
F0cus
  • 585
  • 3
  • 18
  • 52
  • first thing do you have this int-array type custom type? and are you using any library for it – Lucia Jul 13 '21 at 11:28
  • am not using any custom type, in the Entity class, import com.vladmihalcea.hibernate.type.array.IntArrayType; being imported – F0cus Jul 13 '21 at 11:35
  • have you registered this type into hibernate? – Lucia Jul 13 '21 at 11:37
  • See this to how to register type into hibernate. https://stackoverflow.com/questions/67768125/how-to-use-postgresql-array-agg-function-in-jparepository-spring-boot – Lucia Jul 13 '21 at 11:40
  • `@org.springframework.data.jpa.repository.Query com.entity.CombHoldingRule` is an extremely odd conversion target. Please post the full stack trace formatted as code. – Jens Schauder Jul 14 '21 at 07:48

1 Answers1

0

Issue is resolved

Solution that worked for me is below.

In the Entity Class

    @Type(type = "int-array")
    @Column(
            name = "holdingrule_list",
            columnDefinition = "integer[]"
    )
    private int[] holdingRuleList;

In the Repo

   @Query(value="from CombHoldingRule where packageId=:packageId")
    List<CombHoldingRule> repoCHRFromPackageId(@Param("packageId") int packageId);

Thank you @Jens Schauder for the guidance.

F0cus
  • 585
  • 3
  • 18
  • 52