* @param object The object to create.
* @throws MException
*/
public void createObject(DbConnection con, String registryName, Object object) throws MException {
DbConnection myCon = null;
if (con == null) {
try {
myCon = pool.getConnection();
con = myCon;
} catch (Throwable t) {
throw new MException(t);
}
}
if (registryName == null) {
Class<?> clazz = schema.findClassForObject(object,this);
if (clazz == null)
throw new MException("class definition not found for object",object.getClass().getCanonicalName(),registryName);
registryName = clazz.getCanonicalName();
}
Table c = cIndex.get(registryName);
if (c == null)
throw new MException("class definition not found in schema",registryName);
try {
// prepare object
c.prepareCreate(object);
schema.doPreCreate(c,object,con,this);
//save object
c.createObject(con,object);
schema.doPostLoad(c,object,con,this);
} catch (Throwable t) {
throw new MException(registryName,t);
}
if (myCon != null) {
try {
myCon.commit();
} catch (Throwable t) {
throw new MException(t);
}
myCon.close();
}
}