content: /*
   * Copyright (c) 2020 Adam Gaj
   *
   * 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
   *
   *     https://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.adgadev.jplusone.test.domain.commerce;
  
  import lombok.EqualsAndHashCode;
  import lombok.Getter;
  
  import jakarta.persistence.Entity;
  import jakarta.persistence.FetchType;
  import jakarta.persistence.Id;
  import jakarta.persistence.JoinColumn;
  import jakarta.persistence.JoinTable;
  import jakarta.persistence.ManyToMany;
  import jakarta.persistence.ManyToOne;
  import jakarta.persistence.Table;
  import java.util.HashSet;
  import java.util.Set;
  
  @Getter
  @Entity
  @Table(name = "orders")
  @EqualsAndHashCode(onlyExplicitlyIncluded = true)
  public class Order {
  
      @Id
      @EqualsAndHashCode.Include
      private Long id;
  
      private String note;
  
      @ManyToOne(fetch = FetchType.LAZY)
      private Client client;
  
      @ManyToMany(fetch = FetchType.LAZY)
      @JoinTable(
              name = "order_product",
              joinColumns = { @JoinColumn(name = "order_id") },
              inverseJoinColumns = { @JoinColumn(name = "product_id") }
      )
      private Set<Product> products = new HashSet<>();
  
  }
  