【发布时间】:2011-02-28 14:15:14
【问题描述】:
使用播放!框架和它的 JPASupport 类我遇到了遗留数据库的问题。
我有以下课程:
@Entity
@Table(name="product_catalog")
public class ProductCatalog extends JPASupport {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer product_catalog;
@OneToOne
@JoinColumn(name="upper_catalog")
public ProductCatalog upper_catalog;
public String name;
}
某些产品目录没有上层目录,在旧数据库中它被引用为 0。如果我将 upper_catalog 提供为 NULL,那么 JPA 会向该数据库列插入一个 NULL 值。 写入数据库时如何强制 null 值为 0,而从数据库读取时如何强制 null 值为 0?
【问题讨论】:
标签: database jpa null legacy playframework