我正在使用具有整数列和外键的表。这个整数必须是增量的,但是当外键改变时它必须在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 DB)做到这一点?