package com.ilivoo.voom.model.testrecache.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import com.ilivoo.common.recache.annotation.CacheEntity;
import com.ilivoo.common.recache.annotation.Index;
import com.ilivoo.common.recache.annotation.Persister;
import com.ilivoo.common.recache.core.SerializerEntity;
/**
 * 1. 实体类必须存在一个无参数的构造方法
 * @author fengxiang
 *
 */

@Entity
@CacheEntity(size=1000, persister=@Persister("0,30 * * * * ?"))
@NamedQueries({
    @NamedQuery(name="PlayerEntity.name", query="select name from PlayerEntity where id = ?"), 
    @NamedQuery(name="PlayerEntity.account", query="select account from PlayerEntity where id = ?"),
    @NamedQuery(name="PlayerEntity.country", query="select country from PlayerEntity where id = ?")})
public class PlayerEntity extends SerializerEntity<Long> {
    
    @Id
    private Long id;
    
    @Index(query="PlayerEntity.name", unique=true)
    @Column(unique=true, columnDefinition="varchar(200)")
    private String name;
    
    @Index(query="PlayerEntity.account", unique=true)
    @Column(unique=true, columnDefinition="varchar(200)")
    private String account;
    
    @Index(query="PlayerEntity.country")
    @Column(columnDefinition="varchar(50)", nullable=false)
    private String country;
    
    @Column(columnDefinition="int default 0", nullable=false)
    private int adult;
    
    @Column(columnDefinition="bit default 0", nullable=false)
    private boolean gm;
    
    @Lob
    private String json;
    
    private int[] map;
    
    @Override
    public boolean evict() {
	return false;
    }

    @Override
    public Long getId() {
	return id;
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public int getAdult() {
        return adult;
    }

    public void setAdult(int adult) {
        this.adult = adult;
    }

    public boolean isGm() {
        return gm;
    }

    public void setGm(boolean gm) {
        this.gm = gm;
    }

    public String getJson() {
        return json;
    }

    public void setJson(String json) {
        this.json = json;
    }

    public int[] getMap() {
        return map;
    }

    public void setMap(int[] map) {
        this.map = map;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
