CustomEntityImpl framework extension class on which the entity objects are based. Its overridden create() method tests for the presence of a custom attribute-level metadata property named SequenceName and if detected, populates the attribute's default value from the next number in that sequence.
To assign the primary key value using an Oracle sequence:
1. Create the CustomEntityImpl.java file in your project, and insert the code
package eg.alex.karim.model.frameworkExten;
import oracle.jbo.AttributeDef;
import oracle.jbo.AttributeList;
import oracle.jbo.server.EntityImpl;
import oracle.jbo.server.SequenceImpl;
public class CustomEntityImpl extends EntityImpl {
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());
}
}
}
}
import oracle.jbo.AttributeList;
import oracle.jbo.server.EntityImpl;
import oracle.jbo.server.SequenceImpl;
public class CustomEntityImpl extends EntityImpl {
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());
}
}
}
}
2. In the Application Navigator, double-click the entity you want to edit.
3. In the overview editor, click the Attributes navigation tab, and double-click the attribute you want to edit.
4. In the Edit Attribute dialog, set the attribute Type from DBSequance to Number, and then click the Custom Properties node.
5.enable the generation of custom Java classes for an entity object and let it extend CustomEntityImpl.java.
you can download workspace from Here
Summary
by using custom properties you may categorize some attriutes which shared in it's behavior