JPAが表の関連付けをする

628 ワード

詳細

///  
    @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);