DB
//ReceivingGroupService Class // @Scheduled(fixedDelay = 20000L) public void test(){ List<BigInteger> idsCfgAlarmByGroupId = receivingGroupRepository.findIdsCfgAlarmByGroupId(8L); List<Long> ids = listBigToLong(idsCfgAlarmByGroupId); List<ConfiguredAlarm> configuredAlarms = alarmConfigRepository.findByIdIn(ids); } public static List<Long> listBigToLong(List<BigInteger> big) { List<Long> result = new ArrayList<>(); if (big != null) { Iterator item = big.iterator(); while(item.hasNext()) { BigInteger b = (BigInteger)item.next(); result.add(b.longValue()); } } return result; } // ReceivingGroupRepositoryClass @Query(value = "SELECT CONFIGURED_ALARM_ID from OCSGW_ALARM.ALARMS_GROUPS where RECEIVING_GROUP_ID = :groupId", nativeQuery = true) List<BigInteger> findIdsCfgAlarmByGroupId(@Param("groupId")Long groupId); // AlarmConfigRepository -class List<ConfiguredAlarm> findByIdIn(List<Long> ids); Other way to get data
//ConfiguredAlarmRepository @Query(value = "SELECT c FROM ConfiguredAlarm c INNER join AlarmsGroups a on c.id = a.id.configuredAlarmId AND a.id.receivingGroupId = :id") List<ConfiguredAlarm> getConfiguredAlarmByReceivingGroupID(@Param("id") Long id);
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.