我试图通过 idfindById方法获取行,但它没有成功,
无法在 DB 中找到行。当我findAll之前打电话时findById工作正常。我使用 PostgreSQL。
public void updateOffer(OrderOfferDTO orderOfferDTO) {
// List<OrderOfferEntity> all = orderOfferRepository.findAll();
OrderOfferEntity orderOfferEntity = orderOfferRepository.findById(orderOfferDTO.getId()).orElse(null);
assert(orderOfferEntity != null);
if (!isCanOfferUpdate(orderOfferEntity)) return;
orderOfferEntity.setNumberOffer(orderOfferEntity.getNumberOffer() + 1);
orderOfferEntity.setOfferDelivery(orderOfferDTO.getOfferDelivery());
orderOfferEntity.setOfferPickup(orderOfferDTO.getOfferPickup());
orderOfferRepository.save(orderOfferEntity);
}
资料库
@Repository
public interface OrderOfferRepository extends JpaRepository<OrderOfferEntity, Long> {
OrderOfferEntity findByUserEntityAndOrderEntity(UserEntity userEntity, OrderEntity orderEntity);
List<OrderOfferEntity> findByUserEntityNotAndOrderEntity(UserEntity supplierEntity, OrderEntity orderEntity);
List<OrderOfferEntity> findByOrderEntity(OrderEntity orderEntity);
List<OrderOfferEntity> findByUserEntity(UserEntity userEntity);
}
实体
@Entity
@Table(name = "AUCTION_SUPPLIER")
@Data
public class OrderOfferEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "NUMBER_OFFER")
private Integer numberOffer;
@Column(name = "OFFER_PICKUP")
private Integer offerPickup;
@Column(name = "OFFER_DELIVERY")
private Integer offerDelivery;
@Column(name = "IS_ACCEPTED")
private Boolean isAccepted;
@ManyToOne(optional = false)
@JoinColumn(name = "DELIVERY_PROGRESS_ID")
private DeliveryProgressEntity deliveryProgressEntity;
@ManyToOne
@JoinColumn(name = "SUPPLIER_ID", nullable = false)
private UserEntity userEntity;
@ManyToOne
@JoinColumn(name = "CUSTOMER_ORDER_ID", nullable = false)
private OrderEntity orderEntity;
@ManyToOne
@JoinColumn(name = "FACTORY_ID", nullable = false)
}
喵喵时光机
相关分类