// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/entity/PurchaseOrder.java
// @Entity
// public class PurchaseOrder {
// 
//     @Id
//     private String id;
//     private String customerId;
// 
//     @OneToMany(cascade = ALL, fetch = EAGER)
//     @JoinColumn(name = "purchase_order_id")
//     private List<PurchaseOrderItem> purchaseOrderItems = new ArrayList<>();
// 
//     private OffsetDateTime orderDate;
// 
//     public PurchaseOrder(String id, String customerId) {
//         this.id = id;
//         this.customerId = customerId;
//         this.orderDate = OffsetDateTime.now();
//     }
// 
//     public PurchaseOrder addOrderItem(PurchaseOrderItem purchaseOrderItem) {
//         purchaseOrderItems.add(purchaseOrderItem);
//         return this;
//     }
// 
//     private PurchaseOrder() {}
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getCustomerId() {
//         return customerId;
//     }
// 
//     public void setCustomerId(String customerId) {
//         this.customerId = customerId;
//     }
// 
//     public List<PurchaseOrderItem> getPurchaseOrderItems() {
//         return purchaseOrderItems;
//     }
// 
//     public void setPurchaseOrderItems(List<PurchaseOrderItem> purchaseOrderItems) {
//         this.purchaseOrderItems = purchaseOrderItems;
//     }
// 
//     public OffsetDateTime getOrderDate() {
//         return orderDate;
//     }
// 
//     public void setOrderDate(OffsetDateTime orderDate) {
//         this.orderDate = orderDate;
//     }
// }
// 
// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/entity/PurchaseOrderItem.java
// @Entity
// public class PurchaseOrderItem {
// 
//     @Id
//     private String id;
// 
//     private String bookId;
// 
//     public PurchaseOrderItem(String id, String bookId) {
//         this.id = id;
//         this.bookId = bookId;
//     }
// 
//     private PurchaseOrderItem() {}
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getBookId() {
//         return bookId;
//     }
// 
//     public void setBookId(String bookId) {
//         this.bookId = bookId;
//     }
// }
// 
// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/repository/PurchaseOrderRepository.java
// @Repository
// public interface PurchaseOrderRepository extends JpaRepository<PurchaseOrder, String>,
//         JpaSpecificationExecutor<PurchaseOrder> {
// 
//     List<PurchaseOrder> findByCustomerId(String customerId);
// }


import com.codesod.example.jpa.nplusone.entity.PurchaseOrder;
import com.codesod.example.jpa.nplusone.entity.PurchaseOrderItem;
import com.codesod.example.jpa.nplusone.repository.PurchaseOrderRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
/*
 * Copyright 2018 MD Sayem Ahmed
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.codesod.example.jpa.nplusone.service;




/**
 * @author MD Sayem Ahmed
 */
@Service
public class PurchasingService {
    private final PurchaseOrderRepository purchaseOrderRepository;

// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/entity/PurchaseOrder.java
// @Entity
// public class PurchaseOrder {
// 
//     @Id
//     private String id;
//     private String customerId;
// 
//     @OneToMany(cascade = ALL, fetch = EAGER)
//     @JoinColumn(name = "purchase_order_id")
//     private List<PurchaseOrderItem> purchaseOrderItems = new ArrayList<>();
// 
//     private OffsetDateTime orderDate;
// 
//     public PurchaseOrder(String id, String customerId) {
//         this.id = id;
//         this.customerId = customerId;
//         this.orderDate = OffsetDateTime.now();
//     }
// 
//     public PurchaseOrder addOrderItem(PurchaseOrderItem purchaseOrderItem) {
//         purchaseOrderItems.add(purchaseOrderItem);
//         return this;
//     }
// 
//     private PurchaseOrder() {}
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getCustomerId() {
//         return customerId;
//     }
// 
//     public void setCustomerId(String customerId) {
//         this.customerId = customerId;
//     }
// 
//     public List<PurchaseOrderItem> getPurchaseOrderItems() {
//         return purchaseOrderItems;
//     }
// 
//     public void setPurchaseOrderItems(List<PurchaseOrderItem> purchaseOrderItems) {
//         this.purchaseOrderItems = purchaseOrderItems;
//     }
// 
//     public OffsetDateTime getOrderDate() {
//         return orderDate;
//     }
// 
//     public void setOrderDate(OffsetDateTime orderDate) {
//         this.orderDate = orderDate;
//     }
// }
// 
// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/entity/PurchaseOrderItem.java
// @Entity
// public class PurchaseOrderItem {
// 
//     @Id
//     private String id;
// 
//     private String bookId;
// 
//     public PurchaseOrderItem(String id, String bookId) {
//         this.id = id;
//         this.bookId = bookId;
//     }
// 
//     private PurchaseOrderItem() {}
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getBookId() {
//         return bookId;
//     }
// 
//     public void setBookId(String bookId) {
//         this.bookId = bookId;
//     }
// }
// 
// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/repository/PurchaseOrderRepository.java
// @Repository
// public interface PurchaseOrderRepository extends JpaRepository<PurchaseOrder, String>,
//         JpaSpecificationExecutor<PurchaseOrder> {
// 
//     List<PurchaseOrder> findByCustomerId(String customerId);
// }


// Path: jpa-example/src/main/java/com/codesod/example/jpa/nplusone/service/PurchasingService.java
import com.codesod.example.jpa.nplusone.entity.PurchaseOrder;
import com.codesod.example.jpa.nplusone.entity.PurchaseOrderItem;
import com.codesod.example.jpa.nplusone.repository.PurchaseOrderRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;

/*
 * Copyright 2018 MD Sayem Ahmed
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.codesod.example.jpa.nplusone.service;




/**
 * @author MD Sayem Ahmed
 */
@Service
public class PurchasingService {
    private final PurchaseOrderRepository purchaseOrderRepository;

    public PurchasingService(PurchaseOrderRepository purchaseOrderRepository) {