text: /*
   * Copyright (c) 2008-2018 Haulmont.
   *
   * 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.haulmont.cuba.web.testmodel.sales;
  
  import com.haulmont.chile.core.annotations.Composition;
  import com.haulmont.chile.core.annotations.NamePattern;
  import com.haulmont.cuba.core.entity.StandardEntity;
  import com.haulmont.cuba.core.entity.annotation.OnDelete;
  import com.haulmont.cuba.core.global.DeletePolicy;
  import com.haulmont.cuba.security.entity.User;
  
  import javax.persistence.*;
  import java.math.BigDecimal;
  import java.util.Date;
  import java.util.List;
  
  @Entity(name = "test$Order")
  @Table(name = "TEST_ORDER")
  @NamePattern("No %s for %s|number,customer")
  public class Order extends StandardEntity {
  
      @Column(name = "NUM")
      private String number;
  
      @Column(name = "DATE_")
      private Date date;
  
      @Column(name = "AMOUNT")
      private BigDecimal amount;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "CUSTOMER_ID")
      private Customer customer;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "USER_ID")
      private User user;
  
      @Composition
      @OnDelete(DeletePolicy.CASCADE)
      @OneToMany(mappedBy = "order")
      protected List<OrderLine> orderLines;
  
      public String getNumber() {
          return number;
      }
  
      public void setNumber(String number) {
          this.number = number;
      }
  
      public Date getDate() {
          return date;
      }
  
      public void setDate(Date date) {
          this.date = date;
      }
  
      public BigDecimal getAmount() {
          return amount;
      }
  
      public void setAmount(BigDecimal amount) {
          this.amount = amount;
      }
  
      public Customer getCustomer() {
          return customer;
      }
  
      public void setCustomer(Customer customer) {
          this.customer = customer;
      }
  
      public User getUser() {
          return user;
      }
  
      public void setUser(User user) {
          this.user = user;
      }
  
      public List<OrderLine> getOrderLines() {
          return orderLines;
      }
  
      public void setOrderLines(List<OrderLine> orderLines) {
          this.orderLines = orderLines;
      }
  
      @Override
      public String toString() {
          return super.toString() + "@" + Integer.toHexString(System.identityHashCode(this));
      }
  }
  