package org.example.seed.entity;

import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import org.example.seed.catalog.ChefStatus;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * Created by PINA on 24/06/2017.
 */
@Data
@Entity
@Table(name = "chef")
@SQLDelete(sql = "UPDATE chef SET deleted = 1 WHERE id = ?")
@Where(clause = "deleted <> 1")
@EqualsAndHashCode(callSuper = true)
public class ChefEntity extends DatesEntity {

    @Id
    @Column(name = "id", length = 36, nullable = false, updatable = false)
    private String id;

    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "fk_id_account")
    private AccountEntity account;

    @Setter(AccessLevel.NONE)
    @OneToMany(mappedBy = "chef")
    private List<TelephoneEntity> telephones;

    @Column(name = "curp", length = 18)
    private String curp;

    @Column(name = "rfc", length = 13)
    private String rfc;

    @Column(name = "rating")
    private Float rating;

    @Column(name = "status", length = 20)
    @Enumerated(EnumType.STRING)
    private ChefStatus status;

    @Column(name = "deleted")
    private boolean deleted;
}

@@ -31,35 +31,8 @@
 y;%0A%0A
-import lombok.AccessLevel;%0A
 impo
@@ -91,30 +91,8 @@
 ort 
-lombok.Setter;%0Aimport 
 org.
@@ -122,16 +122,100 @@
 efStatus
+;%0Aimport org.hibernate.annotations.Fetch;%0Aimport org.hibernate.annotations.FetchMode
 ;%0Aimport
@@ -775,32 +775,10 @@
 .ALL
-, orphanRemoval = true
 )%0A
+
     
@@ -853,38 +853,8 @@
 t;%0A%0A
-    @Setter(AccessLevel.NONE)%0A
     
@@ -881,16 +881,97 @@
 = %22chef%22
+, fetch = FetchType.EAGER, cascade = CascadeType.ALL)%0A    @Fetch(FetchMode.SELECT
 )%0A    pr

change OneToMany mapping with cascade all property