This can be done by triggers, but when you use Business Components, adding a one method and a single line of groovy code is enough. First, we need a method to get the next DB value:
public Number seqNextVal(String seqName) {
Number seqNextVal;
if(seqName!=null && !seqName.equals("")) {
SequenceImpl seq = new SequenceImpl(seqName, getDBTransaction());
seqNextVal = seq.getSequenceNumber();
}
else {
seqNextVal = new Number(0);
}
return seqNextVal;
}
In the Id-attribute of your entity, you call this method by entering this expression in the value field:
adf.source.seqNextVal("SEQ_NAME")
Don't forget to check the Expression radio!
Hi
ReplyDeleteGood Tip!
You can also set the Type as DBSequence to generate auto-increment.
KR