これはSpringデータJPAの問題です。DBでデータ型がBigIntegerとして定義され、JPAクエリでLongとしてフェッチしようとすると、エラーは発生しませんが、Longデータ型ではBigIntegerとして値が設定されます。
解決策:
-
BigIntegerを使用する リターンタイプとして
@Query(value = "select distinct(oid) from unit", nativeQuery = true) List<BigInteger> testMethod();次に、変数を次のように設定します。
Long variable = bigIntegerValue.longValue(); -
文字列を使用する タイプを返し、Longに変換します
@Query(value = "select distinct(oid) from unit", nativeQuery = true) List<String> testMethod();次に、値を
として設定しますLong variable = Long.valueOf(stringValue); -
DB列タイプの変更 整数/数値に。
-
エンティティから値を取得する オブジェクト。
Long variable = dpConfigData.getOid();ここで、
のオブジェクトですdpConfigDataEntity(DpConfigData.class)