即使禁用了休眠的二级缓存,我也在JSF-Page中显示带有JPA的旧实体数据。

有三个实体:MessageEntities包含DataEntities,而这些实体包含SubDataEntities。

SubDataEntities扩展了两种不同的类型。

我通过将SubDataEntity的数据属性设置为null来临时删除SubDataEntity的实例,并从父实体(DataEntity)的集合中删除该实例。
在ajax请求之后,即使我确实对DB执行成功的删除操作,旧数据仍然显示在JSF-Page中。

MessageEntity:

@Entity(name = "Message")
@Table(name = "message")
public class MessageEntity {


  @Column(name = "version")
  private String               version;

  @Column(name = "variant")
  private String               variant;

  @OneToMany(mappedBy = "message", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
  private List<DataEntity> data;


数据实体:

@Entity(name = "Data")
@Table(name = "data")
public class DataEntity {

  @OneToOne
  @JoinColumn(name = "messageId")
  private MessageEntity     message;

  @OneToMany(mappedBy = "data", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
  private List<SubDataEntity> subData;


SubDataEntity:

@Entity(name = "SubData")
@Table(name = "subData")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class SubDataEntity implements Serializable {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(unique = true, name = "sd_id")
  private Integer            id;

  @OneToOne(cascade = CascadeType.REFRESH)
  @JoinColumn(name = "dataId")
  private DataEntity         data;

  @Column(name = "value")
  private String             value;

最佳答案

导致失败的原因是,该组件在显示和编辑其值的组件中将属性“ immediate”设置为true。
在打开process =“ @ this”和process =“ @ form”之后。

10-06 06:19