JPA做表关联

阅读更多
///客户
    @OneToOne(targetEntity = User.class)
    @JoinColumn(name = "customer_id")
    private String customerId;   //下单客户id



@Query("select new api.xxx.com.petstore.dto.OrderGridDto(o.id,u.mobile,o.orderNo,o.courseName,o.createdDate,o.money,o.status) from SalesOrder o " +
            "left join o.customerId u " +
            "where o.orderNo=?1 and u.mobile = ?2")
    List findAllByOrderQueryDto(String orderNo, String mobile);

你可能感兴趣的:(jpa,OneToOne)