AttributeTypeHasValuesException, NotYetConnectedException, DmsException, DmsDocumentModificationException {
if (oDoc==null) throw new IllegalStateException(getTypeName()+" document not set before calling save() method");
if (DAO.checkConstraints) {
AtrilSession oAdm = DAO.getAdminSession("checkConstraints");
Dms oDms = oAdm.getDms();
DocumentIndexer oIdx = oAdm.getDocumentIndexer();
final Attr[] aAttrs = attributes();
final int nAttrs = (aAttrs==null ? 0 : aAttrs.length);
try {
for (int a=0; a<nAttrs; a++) {
if (aAttrs[a].required && isNull(aAttrs[a].name)) throw new NullPointerException(getTypeName()+" attribute "+aAttrs[a].name+" is required");
if (aAttrs[a].unique && !isNull(aAttrs[a].name)) {
List<Document> oLst;
if (aAttrs[a].dataType.equals(DataType.STRING))
if (getString(aAttrs[a].name).indexOf("'")<0)
oLst = oDms.query(getTypeName()+"$"+aAttrs[a].name+"='"+escape(getString(aAttrs[a].name))+"'");
else
oLst = null;
else if (aAttrs[a].dataType.equals(DataType.NUMBER))
oLst = oDms.query(getTypeName()+"$"+aAttrs[a].name+"="+get(aAttrs[a].name));
else
oLst = null;
if (null!=oLst) {
if (!oLst.isEmpty()) {
String p = parentId();