package com.cc.infosur.greendao;

import de.greenrobot.dao.DaoException;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 
/**
 * Entity mapped to table TRIP_INFO.
 */
public class TripInfo {

    private Long id;
    private String name;
    private java.util.Date dateFrom;
    private java.util.Date dateTo;
    private String json;
    private long userInfoId;

    /** Used to resolve relations */
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    private transient TripInfoDao myDao;

    private TravellerInfo travellerInfo;
    private Long travellerInfo__resolvedKey;


    public TripInfo() {
    }

    public TripInfo(Long id) {
        this.id = id;
    }

    public TripInfo(Long id, String name, java.util.Date dateFrom, java.util.Date dateTo, String json, long userInfoId) {
        this.id = id;
        this.name = name;
        this.dateFrom = dateFrom;
        this.dateTo = dateTo;
        this.json = json;
        this.userInfoId = userInfoId;
    }

    /** called by internal mechanisms, do not call yourself. */
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getTripInfoDao() : null;
    }

    public Long getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

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

    public java.util.Date getDateFrom() {
        return dateFrom;
    }

    public void setDateFrom(java.util.Date dateFrom) {
        this.dateFrom = dateFrom;
    }

    public java.util.Date getDateTo() {
        return dateTo;
    }

    public void setDateTo(java.util.Date dateTo) {
        this.dateTo = dateTo;
    }

    public String getJson() {
        return json;
    }

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

    public long getUserInfoId() {
        return userInfoId;
    }

    public void setUserInfoId(long userInfoId) {
        this.userInfoId = userInfoId;
    }

    /** To-one relationship, resolved on first access. */
    public TravellerInfo getTravellerInfo() {
        long __key = this.userInfoId;
        if (travellerInfo__resolvedKey == null || !travellerInfo__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            TravellerInfoDao targetDao = daoSession.getTravellerInfoDao();
            TravellerInfo travellerInfoNew = targetDao.load(__key);
            synchronized (this) {
                travellerInfo = travellerInfoNew;
            	travellerInfo__resolvedKey = __key;
            }
        }
        return travellerInfo;
    }

    public void setTravellerInfo(TravellerInfo travellerInfo) {
        if (travellerInfo == null) {
            throw new DaoException("To-one property 'userInfoId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.travellerInfo = travellerInfo;
            userInfoId = travellerInfo.getId();
            travellerInfo__resolvedKey = userInfoId;
        }
    }

    /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }    
        myDao.delete(this);
    }

    /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }    
        myDao.update(this);
    }

    /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }    
        myDao.refresh(this);
    }

}
