Playframework Ebean删除对象不刷新Realationship
下面的问题让我感到困惑。我想从关系中删除一个度量值,引用的对象应该更新度量值。所以我的问题是,如果我删除一个度量值,效果很好,但是如果我从cure对象获得所有度量值,我看到delete对象在里面。更新关系的最佳方式是什么 Measurement.javaPlayframework Ebean删除对象不刷新Realationship,playframework,playframework-2.0,ebean,Playframework,Playframework 2.0,Ebean,下面的问题让我感到困惑。我想从关系中删除一个度量值,引用的对象应该更新度量值。所以我的问题是,如果我删除一个度量值,效果很好,但是如果我从cure对象获得所有度量值,我看到delete对象在里面。更新关系的最佳方式是什么 Measurement.java @Entity @Table(name = "measurements") public class Measurement extends Model { @Id public Long id; @Formats.
@Entity
@Table(name = "measurements")
public class Measurement extends Model {
@Id
public Long id;
@Formats.DateTime(pattern = "dd.MM.yyyy")
public Date created = new Date();
@Constraints.Required
public double weight;
@Constraints.Required
public double belly;
@Constraints.Required
public double thigh;
@Constraints.Required
public double gluteal;
@ManyToOne
@JsonBackReference
public Cure cure;
}
Cure.java
@Entity
@Table(name = "cures")
public class Cure extends Model implements Comparable<Cure> {
@Id
public Long id;
@Formats.DateTime(pattern = "dd.MM.yyyy")
public Date created = new Date();
public int startHour = 10;
@ManyToOne
@JsonIgnore
public Challenge challenge;
@JsonManagedReference
@OneToMany
public List<Measurement> measurements;
}
我在你的模特课上没看到finder。执行以下步骤
public static Finder<Long, Measurement> find = new Finder<Long, Measurement>(Long.class, Measurement.class);
public static Finder<Long, Measurement> find = new Finder<Long, Measurement>(Long.class, Measurement.class);
SqlUpdate deletObject = Ebean
.createSqlUpdate("delete from table_name where id = "
+ id);
deletObject.execute();