JPA替换数据库注释

时间:2014-09-23 15:19:16

标签: java jpa replace annotations unique

我有这堂课:

@Entity
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "date", 
    "meterTime" }) })
public class Meter {

    public enum MeterTime {
        AFTER_FAST, AFTER_MEAL
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    private Date date;

    @Enumerated(EnumType.STRING)
    private MeterTime meterTime;

    private Float meter;

    // constructor, getters and setters

}

现在,当我尝试插入一个日期和米时已存在的行时,该行未插入..

但!我想插入(并替换现有的行)

我该怎么做?

谢谢!

0 个答案:

没有答案