package com.sysu.admin.controller.lz.group;

import com.alibaba.fastjson.annotation.JSONField;
import com.sysu.admin.controller.lz.group_item.LzGroupItem;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.locationtech.jts.geom.Point;

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

@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@FieldNameConstants(innerTypeName = "FIELDS")
@Table(name = "lz_group")
@Entity
@DynamicInsert
@DynamicUpdate
public class LzGroup {

    @Id
    private Integer id;
    private Integer areaId;
    @JSONField(serialize = false)
    @Column(name = "point")
    private Point point;

    @Transient
    private String wkt;

    @OneToMany(fetch = FetchType.EAGER,cascade={CascadeType.ALL}, mappedBy = "pk.groupId")
    private List<LzGroupItem> items;


}
