我试图用findById
方法按ID获取行,但它不成功
在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)
private FactoryEntity factoryEntity;
@ManyToOne
@JoinColumn(name = "FORMULA_ID", nullable = false)
private FormulaEntity formulaEntity;
@ManyToOne
@JoinColumn(name = "PACKING_ID", nullable = false)
private PackingEntity packingEntity;
}
生成的SQL
Hibernate:
select
orderoffer0_.id as id1_1_0_,
orderoffer0_.delivery_progress_id as delivery6_1_0_,
orderoffer0_.factory_id as factory_7_1_0_,
orderoffer0_.formula_id as formula_8_1_0_,
orderoffer0_.is_accepted as is_accep2_1_0_,
orderoffer0_.number_offer as number_o3_1_0_,
orderoffer0_.offer_delivery as offer_de4_1_0_,
orderoffer0_.offer_pickup as offer_pi5_1_0_,
orderoffer0_.customer_order_id as customer9_1_0_,
orderoffer0_.packing_id as packing10_1_0_,
orderoffer0_.supplier_id as supplie11_1_0_,
deliverypr1_.id as id1_6_1_,
deliverypr1_.is_pickup as is_picku2_6_1_,
deliverypr1_.name_progress as name_pro3_6_1_,
deliverypr1_.progress_position as progress4_6_1_,
factoryent2_.id as id1_7_2_,
factoryent2_.address as address2_7_2_,
factoryent2_.name as name3_7_2_,
formulaent3_.id as id1_13_3_,
formulaent3_.name as name2_13_3_,
orderentit4_.id as id1_5_4_,
orderentit4_.auction_progress_id as auction_9_5_4_,
orderentit4_.end_datetime_auction as end_date2_5_4_,
orderentit4_.end_datetime_auction_step as end_date3_5_4_,
orderentit4_.max_date as max_date4_5_4_,
orderentit4_.card_delivery_id as card_de10_5_4_,
orderentit4_.fertilizer_id as fertili11_5_4_,
orderentit4_.is_active as is_activ5_5_4_,
orderentit4_.is_delivery as is_deliv6_5_4_,
orderentit4_.is_pickup as is_picku7_5_4_,
orderentit4_.card_pickup_id as card_pi12_5_4_,
orderentit4_.customer_id as custome13_5_4_,
orderentit4_.volume_fertilizer as volume_f8_5_4_,
auctionpro5_.id as id1_0_5_,
auctionpro5_.hours_on_progress as hours_on2_0_5_,
auctionpro5_.is_end_auction as is_end_a3_0_5_,
auctionpro5_.is_final_step as is_final4_0_5_,
auctionpro5_.name_progress as name_pro5_0_5_,
deliveryma6_.id as id1_3_6_,
deliveryma6_.address as address2_3_6_,
deliveryma6_.customer_id as customer3_3_6_,
userentity7_.id as id1_20_7_,
userentity7_.active as active2_20_7_,
userentity7_.bank_id as bank_id11_20_7_,
userentity7_.business_address as business3_20_7_,
userentity7_.company_name as company_4_20_7_,
userentity7_.email as email5_20_7_,
userentity7_.inn as inn6_20_7_,
userentity7_.kpp as kpp7_20_7_,
userentity7_.ogrn as ogrn8_20_7_,
userentity7_.password as password9_20_7_,
userentity7_.phone_number as phone_n10_20_7_,
userentity7_.role_id as role_id12_20_7_,
bankentity8_.id as id1_2_8_,
bankentity8_.account as account2_2_8_,
bankentity8_.bic as bic3_2_8_,
bankentity8_.name as name4_2_8_,
roleentity9_.id as id1_21_9_,
roleentity9_.name_role as name_rol2_21_9_,
fertilizer10_.id as id1_9_10_,
fertilizer10_.name as name2_9_10_,
pickupmape11_.id as id1_4_11_,
pickupmape11_.center_address as center_a2_4_11_,
pickupmape11_.radius_value as radius_v3_4_11_,
pickupmape11_.customer_id as customer4_4_11_,
userentity12_.id as id1_20_12_,
userentity12_.active as active2_20_12_,
userentity12_.bank_id as bank_id11_20_12_,
userentity12_.business_address as business3_20_12_,
userentity12_.company_name as company_4_20_12_,
userentity12_.email as email5_20_12_,
userentity12_.inn as inn6_20_12_,
userentity12_.kpp as kpp7_20_12_,
userentity12_.ogrn as ogrn8_20_12_,
userentity12_.password as password9_20_12_,
userentity12_.phone_number as phone_n10_20_12_,
userentity12_.role_id as role_id12_20_12_,
userentity13_.id as id1_20_13_,
userentity13_.active as active2_20_13_,
userentity13_.bank_id as bank_id11_20_13_,
userentity13_.business_address as business3_20_13_,
userentity13_.company_name as company_4_20_13_,
userentity13_.email as email5_20_13_,
userentity13_.inn as inn6_20_13_,
userentity13_.kpp as kpp7_20_13_,
userentity13_.ogrn as ogrn8_20_13_,
userentity13_.password as password9_20_13_,
userentity13_.phone_number as phone_n10_20_13_,
userentity13_.role_id as role_id12_20_13_,
packingent14_.id as id1_19_14_,
packingent14_.name as name2_19_14_,
userentity15_.id as id1_20_15_,
userentity15_.active as active2_20_15_,
userentity15_.bank_id as bank_id11_20_15_,
userentity15_.business_address as business3_20_15_,
userentity15_.company_name as company_4_20_15_,
userentity15_.email as email5_20_15_,
userentity15_.inn as inn6_20_15_,
userentity15_.kpp as kpp7_20_15_,
userentity15_.ogrn as ogrn8_20_15_,
userentity15_.password as password9_20_15_,
userentity15_.phone_number as phone_n10_20_15_,
userentity15_.role_id as role_id12_20_15_
from
auction_supplier orderoffer0_
inner join
delivery_progress deliverypr1_
on orderoffer0_.delivery_progress_id=deliverypr1_.id
inner join
factory factoryent2_
on orderoffer0_.factory_id=factoryent2_.id
inner join
formula formulaent3_
on orderoffer0_.formula_id=formulaent3_.id
inner join
customer_order orderentit4_
on orderoffer0_.customer_order_id=orderentit4_.id
left outer join
auction_progress auctionpro5_
on orderentit4_.auction_progress_id=auctionpro5_.id
left outer join
card_delivery deliveryma6_
on orderentit4_.card_delivery_id=deliveryma6_.id
left outer join
portal_user userentity7_
on deliveryma6_.customer_id=userentity7_.id
left outer join
bank bankentity8_
on userentity7_.bank_id=bankentity8_.id
left outer join
role roleentity9_
on userentity7_.role_id=roleentity9_.id
inner join
fertilizer fertilizer10_
on orderentit4_.fertilizer_id=fertilizer10_.id
left outer join
card_pickup pickupmape11_
on orderentit4_.card_pickup_id=pickupmape11_.id
left outer join
portal_user userentity12_
on pickupmape11_.customer_id=userentity12_.id
inner join
portal_user userentity13_
on orderentit4_.customer_id=userentity13_.id
inner join
packing packingent14_
on orderoffer0_.packing_id=packingent14_.id
inner join
portal_user userentity15_
on orderoffer0_.supplier_id=userentity15_.id
where
orderoffer0_.id=?
当我在findByID之前使用findAll时,这会生成SQL
Hibernate:
select
orderoffer0_.id as id1_1_,
orderoffer0_.delivery_progress_id as delivery6_1_,
orderoffer0_.factory_id as factory_7_1_,
orderoffer0_.formula_id as formula_8_1_,
orderoffer0_.is_accepted as is_accep2_1_,
orderoffer0_.number_offer as number_o3_1_,
orderoffer0_.offer_delivery as offer_de4_1_,
orderoffer0_.offer_pickup as offer_pi5_1_,
orderoffer0_.customer_order_id as customer9_1_,
orderoffer0_.packing_id as packing10_1_,
orderoffer0_.supplier_id as supplie11_1_
from
auction_supplier orderoffer0_
Hibernate:
select
factoryent0_.id as id1_7_0_,
factoryent0_.address as address2_7_0_,
factoryent0_.name as name3_7_0_
from
factory factoryent0_
where
factoryent0_.id=?
Hibernate:
select
formulaent0_.id as id1_13_0_,
formulaent0_.name as name2_13_0_
from
formula formulaent0_
where
formulaent0_.id=?
Hibernate:
select
orderentit0_.id as id1_5_0_,
orderentit0_.auction_progress_id as auction_9_5_0_,
orderentit0_.end_datetime_auction as end_date2_5_0_,
orderentit0_.end_datetime_auction_step as end_date3_5_0_,
orderentit0_.max_date as max_date4_5_0_,
orderentit0_.card_delivery_id as card_de10_5_0_,
orderentit0_.fertilizer_id as fertili11_5_0_,
orderentit0_.is_active as is_activ5_5_0_,
orderentit0_.is_delivery as is_deliv6_5_0_,
orderentit0_.is_pickup as is_picku7_5_0_,
orderentit0_.card_pickup_id as card_pi12_5_0_,
orderentit0_.customer_id as custome13_5_0_,
orderentit0_.volume_fertilizer as volume_f8_5_0_,
auctionpro1_.id as id1_0_1_,
auctionpro1_.hours_on_progress as hours_on2_0_1_,
auctionpro1_.is_end_auction as is_end_a3_0_1_,
auctionpro1_.is_final_step as is_final4_0_1_,
auctionpro1_.name_progress as name_pro5_0_1_,
deliveryma2_.id as id1_3_2_,
deliveryma2_.address as address2_3_2_,
deliveryma2_.customer_id as customer3_3_2_,
userentity3_.id as id1_20_3_,
userentity3_.active as active2_20_3_,
userentity3_.bank_id as bank_id11_20_3_,
userentity3_.business_address as business3_20_3_,
userentity3_.company_name as company_4_20_3_,
userentity3_.email as email5_20_3_,
userentity3_.inn as inn6_20_3_,
userentity3_.kpp as kpp7_20_3_,
userentity3_.ogrn as ogrn8_20_3_,
userentity3_.password as password9_20_3_,
userentity3_.phone_number as phone_n10_20_3_,
userentity3_.role_id as role_id12_20_3_,
bankentity4_.id as id1_2_4_,
bankentity4_.account as account2_2_4_,
bankentity4_.bic as bic3_2_4_,
bankentity4_.name as name4_2_4_,
roleentity5_.id as id1_21_5_,
roleentity5_.name_role as name_rol2_21_5_,
fertilizer6_.id as id1_9_6_,
fertilizer6_.name as name2_9_6_,
pickupmape7_.id as id1_4_7_,
pickupmape7_.center_address as center_a2_4_7_,
pickupmape7_.radius_value as radius_v3_4_7_,
pickupmape7_.customer_id as customer4_4_7_,
userentity8_.id as id1_20_8_,
userentity8_.active as active2_20_8_,
userentity8_.bank_id as bank_id11_20_8_,
userentity8_.business_address as business3_20_8_,
userentity8_.company_name as company_4_20_8_,
userentity8_.email as email5_20_8_,
userentity8_.inn as inn6_20_8_,
userentity8_.kpp as kpp7_20_8_,
userentity8_.ogrn as ogrn8_20_8_,
userentity8_.password as password9_20_8_,
userentity8_.phone_number as phone_n10_20_8_,
userentity8_.role_id as role_id12_20_8_,
userentity9_.id as id1_20_9_,
userentity9_.active as active2_20_9_,
userentity9_.bank_id as bank_id11_20_9_,
userentity9_.business_address as business3_20_9_,
userentity9_.company_name as company_4_20_9_,
userentity9_.email as email5_20_9_,
userentity9_.inn as inn6_20_9_,
userentity9_.kpp as kpp7_20_9_,
userentity9_.ogrn as ogrn8_20_9_,
userentity9_.password as password9_20_9_,
userentity9_.phone_number as phone_n10_20_9_,
userentity9_.role_id as role_id12_20_9_
from
customer_order orderentit0_
left outer join
auction_progress auctionpro1_
on orderentit0_.auction_progress_id=auctionpro1_.id
left outer join
card_delivery deliveryma2_
on orderentit0_.card_delivery_id=deliveryma2_.id
left outer join
portal_user userentity3_
on deliveryma2_.customer_id=userentity3_.id
left outer join
bank bankentity4_
on userentity3_.bank_id=bankentity4_.id
left outer join
role roleentity5_
on userentity3_.role_id=roleentity5_.id
inner join
fertilizer fertilizer6_
on orderentit0_.fertilizer_id=fertilizer6_.id
left outer join
card_pickup pickupmape7_
on orderentit0_.card_pickup_id=pickupmape7_.id
left outer join
portal_user userentity8_
on pickupmape7_.customer_id=userentity8_.id
inner join
portal_user userentity9_
on orderentit0_.customer_id=userentity9_.id
where
orderentit0_.id=?
Hibernate:
select
bankentity0_.id as id1_2_0_,
bankentity0_.account as account2_2_0_,
bankentity0_.bic as bic3_2_0_,
bankentity0_.name as name4_2_0_
from
bank bankentity0_
where
bankentity0_.id=?
Hibernate:
select
roleentity0_.id as id1_21_0_,
roleentity0_.name_role as name_rol2_21_0_
from
role roleentity0_
where
roleentity0_.id=?
Hibernate:
select
packingent0_.id as id1_19_0_,
packingent0_.name as name2_19_0_
from
packing packingent0_
where
packingent0_.id=?
Hibernate:
select
userentity0_.id as id1_20_0_,
userentity0_.active as active2_20_0_,
userentity0_.bank_id as bank_id11_20_0_,
userentity0_.business_address as business3_20_0_,
userentity0_.company_name as company_4_20_0_,
userentity0_.email as email5_20_0_,
userentity0_.inn as inn6_20_0_,
userentity0_.kpp as kpp7_20_0_,
userentity0_.ogrn as ogrn8_20_0_,
userentity0_.password as password9_20_0_,
userentity0_.phone_number as phone_n10_20_0_,
userentity0_.role_id as role_id12_20_0_,
bankentity1_.id as id1_2_1_,
bankentity1_.account as account2_2_1_,
bankentity1_.bic as bic3_2_1_,
bankentity1_.name as name4_2_1_,
roleentity2_.id as id1_21_2_,
roleentity2_.name_role as name_rol2_21_2_
from
portal_user userentity0_
inner join
bank bankentity1_
on userentity0_.bank_id=bankentity1_.id
inner join
role roleentity2_
on userentity0_.role_id=roleentity2_.id
where
userentity0_.id=?
Hibernate:
update
auction_supplier
set
delivery_progress_id=?,
factory_id=?,
formula_id=?,
is_accepted=?,
number_offer=?,
offer_delivery=?,
offer_pickup=?,
customer_order_id=?,
packing_id=?,
supplier_id=?
where
id=?
Hibernate:
select
userentity0_.id as id1_20_,
userentity0_.active as active2_20_,
userentity0_.bank_id as bank_id11_20_,
userentity0_.business_address as business3_20_,
userentity0_.company_name as company_4_20_,
userentity0_.email as email5_20_,
userentity0_.inn as inn6_20_,
userentity0_.kpp as kpp7_20_,
userentity0_.ogrn as ogrn8_20_,
userentity0_.password as password9_20_,
userentity0_.phone_number as phone_n10_20_,
userentity0_.role_id as role_id12_20_
from
portal_user userentity0_
where
userentity0_.inn=?
Hibernate:
select
bankentity0_.id as id1_2_0_,
bankentity0_.account as account2_2_0_,
bankentity0_.bic as bic3_2_0_,
bankentity0_.name as name4_2_0_
from
bank bankentity0_
where
bankentity0_.id=?
Hibernate:
select
roleentity0_.id as id1_21_0_,
roleentity0_.name_role as name_rol2_21_0_
from
role roleentity0_
where
roleentity0_.id=?
Hibernate:
select
userentity0_.id as id1_20_,
userentity0_.active as active2_20_,
userentity0_.bank_id as bank_id11_20_,
userentity0_.business_address as business3_20_,
userentity0_.company_name as company_4_20_,
userentity0_.email as email5_20_,
userentity0_.inn as inn6_20_,
userentity0_.kpp as kpp7_20_,
userentity0_.ogrn as ogrn8_20_,
userentity0_.password as password9_20_,
userentity0_.phone_number as phone_n10_20_,
userentity0_.role_id as role_id12_20_
from
portal_user userentity0_
where
userentity0_.inn=?
Hibernate:
select
bankentity0_.id as id1_2_0_,
bankentity0_.account as account2_2_0_,
bankentity0_.bic as bic3_2_0_,
bankentity0_.name as name4_2_0_
from
bank bankentity0_
where
bankentity0_.id=?
Hibernate:
select
roleentity0_.id as id1_21_0_,
roleentity0_.name_role as name_rol2_21_0_
from
role roleentity0_
where
roleentity0_.id=?
Hibernate:
select
orderentit0_.id as id1_5_0_,
orderentit0_.auction_progress_id as auction_9_5_0_,
orderentit0_.end_datetime_auction as end_date2_5_0_,
orderentit0_.end_datetime_auction_step as end_date3_5_0_,
orderentit0_.max_date as max_date4_5_0_,
orderentit0_.card_delivery_id as card_de10_5_0_,
orderentit0_.fertilizer_id as fertili11_5_0_,
orderentit0_.is_active as is_activ5_5_0_,
orderentit0_.is_delivery as is_deliv6_5_0_,
orderentit0_.is_pickup as is_picku7_5_0_,
orderentit0_.card_pickup_id as card_pi12_5_0_,
orderentit0_.customer_id as custome13_5_0_,
orderentit0_.volume_fertilizer as volume_f8_5_0_,
auctionpro1_.id as id1_0_1_,
auctionpro1_.hours_on_progress as hours_on2_0_1_,
auctionpro1_.is_end_auction as is_end_a3_0_1_,
auctionpro1_.is_final_step as is_final4_0_1_,
auctionpro1_.name_progress as name_pro5_0_1_,
deliveryma2_.id as id1_3_2_,
deliveryma2_.address as address2_3_2_,
deliveryma2_.customer_id as customer3_3_2_,
userentity3_.id as id1_20_3_,
userentity3_.active as active2_20_3_,
userentity3_.bank_id as bank_id11_20_3_,
userentity3_.business_address as business3_20_3_,
userentity3_.company_name as company_4_20_3_,
userentity3_.email as email5_20_3_,
userentity3_.inn as inn6_20_3_,
userentity3_.kpp as kpp7_20_3_,
userentity3_.ogrn as ogrn8_20_3_,
userentity3_.password as password9_20_3_,
userentity3_.phone_number as phone_n10_20_3_,
userentity3_.role_id as role_id12_20_3_,
bankentity4_.id as id1_2_4_,
bankentity4_.account as account2_2_4_,
bankentity4_.bic as bic3_2_4_,
bankentity4_.name as name4_2_4_,
roleentity5_.id as id1_21_5_,
roleentity5_.name_role as name_rol2_21_5_,
fertilizer6_.id as id1_9_6_,
fertilizer6_.name as name2_9_6_,
pickupmape7_.id as id1_4_7_,
pickupmape7_.center_address as center_a2_4_7_,
pickupmape7_.radius_value as radius_v3_4_7_,
pickupmape7_.customer_id as customer4_4_7_,
userentity8_.id as id1_20_8_,
userentity8_.active as active2_20_8_,
userentity8_.bank_id as bank_id11_20_8_,
userentity8_.business_address as business3_20_8_,
userentity8_.company_name as company_4_20_8_,
userentity8_.email as email5_20_8_,
userentity8_.inn as inn6_20_8_,
userentity8_.kpp as kpp7_20_8_,
userentity8_.ogrn as ogrn8_20_8_,
userentity8_.password as password9_20_8_,
userentity8_.phone_number as phone_n10_20_8_,
userentity8_.role_id as role_id12_20_8_,
userentity9_.id as id1_20_9_,
userentity9_.active as active2_20_9_,
userentity9_.bank_id as bank_id11_20_9_,
userentity9_.business_address as business3_20_9_,
userentity9_.company_name as company_4_20_9_,
userentity9_.email as email5_20_9_,
userentity9_.inn as inn6_20_9_,
userentity9_.kpp as kpp7_20_9_,
userentity9_.ogrn as ogrn8_20_9_,
userentity9_.password as password9_20_9_,
userentity9_.phone_number as phone_n10_20_9_,
userentity9_.role_id as role_id12_20_9_
from
customer_order orderentit0_
left outer join
auction_progress auctionpro1_
on orderentit0_.auction_progress_id=auctionpro1_.id
left outer join
card_delivery deliveryma2_
on orderentit0_.card_delivery_id=deliveryma2_.id
left outer join
portal_user userentity3_
on deliveryma2_.customer_id=userentity3_.id
left outer join
bank bankentity4_
on userentity3_.bank_id=bankentity4_.id
left outer join
role roleentity5_
on userentity3_.role_id=roleentity5_.id
inner join
fertilizer fertilizer6_
on orderentit0_.fertilizer_id=fertilizer6_.id
left outer join
card_pickup pickupmape7_
on orderentit0_.card_pickup_id=pickupmape7_.id
left outer join
portal_user userentity8_
on pickupmape7_.customer_id=userentity8_.id
inner join
portal_user userentity9_
on orderentit0_.customer_id=userentity9_.id
where
orderentit0_.id=?
Hibernate:
select
roleentity0_.id as id1_21_0_,
roleentity0_.name_role as name_rol2_21_0_
from
role roleentity0_
where
roleentity0_.id=?
Hibernate:
select
orderoffer0_.id as id1_1_,
orderoffer0_.delivery_progress_id as delivery6_1_,
orderoffer0_.factory_id as factory_7_1_,
orderoffer0_.formula_id as formula_8_1_,
orderoffer0_.is_accepted as is_accep2_1_,
orderoffer0_.number_offer as number_o3_1_,
orderoffer0_.offer_delivery as offer_de4_1_,
orderoffer0_.offer_pickup as offer_pi5_1_,
orderoffer0_.customer_order_id as customer9_1_,
orderoffer0_.packing_id as packing10_1_,
orderoffer0_.supplier_id as supplie11_1_
from
auction_supplier orderoffer0_
where
orderoffer0_.supplier_id=?
and orderoffer0_.customer_order_id=?
Hibernate:
select
factoryent0_.id as id1_7_0_,
factoryent0_.address as address2_7_0_,
factoryent0_.name as name3_7_0_
from
factory factoryent0_
where
factoryent0_.id=?
Hibernate:
select
formulaent0_.id as id1_13_0_,
formulaent0_.name as name2_13_0_
from
formula formulaent0_
where
formulaent0_.id=?
Hibernate:
select
packingent0_.id as id1_19_0_,
packingent0_.name as name2_19_0_
from
packing packingent0_
where
packingent0_.id=?
最佳答案
您所有的ManyToOne关系都是非可选的或非空的。
因此,Hibernate生成INNER JOINS。您必须确保您的数据遵循此规则。
如果定义非可选关系或非null关系,则还应对数据库表中的外键具有NOT NULL约束。