CAST假阳性警告使用延迟获取进行收集

时间:2019-03-13 14:08:09

标签: java hibernate jpa spring-data-jpa

我的办公室有很多警告,提示实体类的配置不正确。该警告是由CAST代码分析工具生成的Use lazy fetching for collection。我不知道为什么会发出警告!在我看来,所有警告都是假阳性-类通过fetch = FetchType.LAZY参数连接。这是一个示例:

@Entity
@Table(name = "LANGUAGE")
public class Language implements Serializable {

  private static final long serialVersionUID = -817366943253128612L;

  @JsonIgnore
  @OneToMany(mappedBy = "language", fetch = FetchType.LAZY)
  private List<Translation> translations;

  @Id
  @Basic(optional = false)
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "ID")
  private Long id;

  **************
}

@Entity
@Table(name = "TRANSLATION")
public class Translation implements Serializable {

  private static final long serialVersionUID = -2083613768351231471L;

  @JoinColumn(name = "R_LANGUAGE_ID", referencedColumnName = "ID")
  @ManyToOne(
      fetch = FetchType.LAZY,
      cascade = { CascadeType.REFRESH, CascadeType.MERGE, CascadeType.PERSIST })
  private Language language;

  @Id
  @Basic(optional = false)
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "ID")
  private Long id;

  *******

 }

我做错了什么还是真的是假阳性警告?

Java(TM) SE运行时环境(内部版本1.8.0_191-b12)

Spring1.5.4.RELEASE

0 个答案:

没有答案