我在我的表实体中使用以下代码来过滤掉所有is_pooled = true的记录。(@Where(clause = "is_pooled = false")
)
@Entity
@Table(name = "bbser_inventory")
@Getter
@Setter
@NoArgsConstructor
@Where(clause = "is_pooled = false")
public class InventoryEntity extends BaseEntity {
字符串
但是有一个例外情况,我需要在数据库中检索is_pooled值设置为true的数据。我如何实现这一点?
我已经试过写以下解决方案,但不检索数据
方法一
List<InventoryEntity> findAllByInventoryIdInAndIsPooledTrue(List<Long> inventoryIdList);
型
方法二
@Query("SELECT i FROM InventoryEntity i WHERE i.inventoryId IN (?1) AND i.isPooled = true")
List<InventoryEntity> findInventoryByIdAndIsPooled(Collection<Long> inventoryIds, Boolean ispooled);
型
下面是我的serviceImpl方法,我试图检索此数据
@Override
public ResponseEntity<?> getPooledParentInfo(Long inventoryId) {
PooledBloodInventoryEntity pooledBloodInventoryEntity = pooledInventoryRepository.findDistinctFirstByInventoryId(inventoryId);
List<Long> pooledInventoryIdList = pooledBloodInventoryEntity.getParentInventoryIds();
List<InventoryEntity> inventoryEntityList = inventoryRepository.findInventoryByIdAndIsPooled(pooledInventoryIdList, true);
return new ResponseEntity<>(inventoryEntityList, new HttpHeaders(), HttpStatus.OK);
}
型
1条答案
按热度按时间col17t5w1#
下面的例子可能会很有用。@在原生查询中注解不起作用的地方
字符串