第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

我厭倦了用 JpaRepository 做點(diǎn)什么但是找不到行 findById ,

我厭倦了用 JpaRepository 做點(diǎn)什么但是找不到行 findById ,

動(dòng)漫人物 2023-06-21 16:39:35
我試圖通過 idfindById方法獲取行,但它沒有成功,無法在 DB 中找到行。當(dāng)我findAll之前打電話時(shí)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);    }資料庫@Repositorypublic 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);}實(shí)體@Entity@Table(name = "AUCTION_SUPPLIER")@Datapublic 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)}
查看完整描述

1 回答

?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

您所有的 ManyToOne 關(guān)系都是非可選的或非空的。

所以 Hibernate 生成 INNER JOINS。您必須確保您的數(shù)據(jù)遵循此規(guī)則。

如果您定義非可選或非空關(guān)系,您還應(yīng)該對(duì)數(shù)據(jù)庫表中的外鍵設(shè)置 NOT NULL 約束。


查看完整回答
反對(duì) 回復(fù) 2023-06-21
  • 1 回答
  • 0 關(guān)注
  • 249 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)