本文主要介绍如何在ADF中使用Sequence,具体步骤如下:
1、 选择EO中需要使用Sequence的属性,双击该属性
2、 在Edit Attribute中选择Custom Properties选项
3、 新建Custom Properties,Name为SequenceName,Value为数据库中Sequence的名字,完成后单击Add
4、 选择EO的Impl类,重写create方法,代码如下:
/**
* Add attribute defaulting logic in this method.
* @param attributeList list of attribute names/values to initialize the row
*/
protected void create(AttributeList attributeList) {
super.create(attributeList);
for (AttributeDef def : getEntityDef().getAttributeDefs()) {
String sequenceName = (String)def.getProperty("SequenceName");
if (sequenceName != null) {
SequenceImpl s =
new SequenceImpl(sequenceName, getDBTransaction());
setAttribute(def.getIndex(), s.getSequenceNumber());
}
}
}
0 评论:
发表评论