在春天无法从数据库中获取瞬态字段

时间:2017-06-03 09:04:46

标签: spring spring-data

我制作了一个网络抓取工具,可以从网站抓取数据并将数据保存在数据库中。数据库的字段是

occasions
day
data
state

现在我向数据库添加了一个额外的字段图像,我不得不手动设置数据库中的图像值,因为我没有从网络爬虫中获取该字段。所以我在我的hibernate模型类中创建了字段图像@transient

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name="Holidays")
public class Holidays implements Serializable {
    private static final long serialVersionUID = 6705527563808382509L;
    String day;
    String date;
    @Id
    String occasion;
    @Transient
    String image;
    public String getImage() {
        return image;
    }
    public void setImage(String image) {
        this.image = image;
    }
    String state;
    @Override
    public String toString() {
        return "Holidays [day=" + day + ", date=" + date + ", occasion=" + occasion + ", state=" + state + "]";
    }
    public Holidays() {
        super();
        // TODO Auto-generated constructor stub
    }
    public Holidays(String day, String date, String occasion, String state) {
        super();
        this.day = day;
        this.date = date;
        this.occasion = occasion;
        this.state = state;
        this.image=image;
    }
    public String getDay() {
        return day;
    }
    public void setDay(String day) {
        this.day = day;
    }
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public String getOccasion() {
        return occasion;
    }
    public void setOccasion(String occasion) {
        this.occasion = occasion;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }

}

现在填充字段图像后我想从数据库中获取此字段但是显示为null。是否是由于瞬态属性?请指导

0 个答案:

没有答案