根据外键自动递增Hibernate的非主键(Hibernate AutoIncrement non

2019-10-21 02:10发布

我与具有整列和外键的表工作。 这个整数必须是渐进的,但它具有当外键被改变为1再次启动。

例:

Foreign 1, int col : 1 , 2 , 3...

Foreign 2, int col: 1 ,2 , 3, 4, 5 ...

Foreign 3, int col: 1, 2

这是我的映射至今:(当然,这并不能做的伎俩)

public class Documento implements ModelEntity{

private static final long serialVersionUID = 11233L;

/*PK*/
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

/*FK*/
@Man yToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "type_id")
@Cascade({})
private Type type;

/* This is the value that has to be AUTO-INCREMENT BASED ON FOREIGN_ID */
@Basic
private Integer idx;


}    

有没有一种方法使用Hibernate(Oracle数据库)来做到这一点?

文章来源: Hibernate AutoIncrement non primary key based on foreign key