use of lucee.runtime.orm.ORMSession in project Lucee by lucee.
the class EntitySave method call.
public static String call(PageContext pc, Object obj, boolean forceInsert) throws PageException {
ORMSession session = ORMUtil.getSession(pc);
session.save(pc, obj, forceInsert);
return null;
}
use of lucee.runtime.orm.ORMSession in project Lucee by lucee.
the class ORMExecuteQuery method _call.
private static Object _call(PageContext pc, String hql, Object params, boolean unique, Struct queryOptions) throws PageException {
ORMSession session = ORMUtil.getSession(pc);
String dsn = null;
if (queryOptions != null)
dsn = Caster.toString(queryOptions.get(KeyConstants._datasource, null), null);
if (StringUtil.isEmpty(dsn, true))
dsn = ORMUtil.getDefaultDataSource(pc).getName();
if (params == null)
return toCFML(session.executeQuery(pc, dsn, hql, new ArrayImpl(), unique, queryOptions));
else if (Decision.isStruct(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toStruct(params), unique, queryOptions));
else if (Decision.isArray(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toArray(params), unique, queryOptions));
else if (Decision.isCastableToStruct(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toStruct(params), unique, queryOptions));
else if (Decision.isCastableToArray(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toArray(params), unique, queryOptions));
else
throw new FunctionException(pc, "ORMExecuteQuery", 2, "params", "cannot convert the params to a array or a struct");
}
use of lucee.runtime.orm.ORMSession in project Lucee by lucee.
the class ORMReload method call.
public static String call(PageContext pc) throws PageException {
// flush and close session
ORMSession session = ORMUtil.getSession(pc, false);
if (session != null) {
// MUST do the same with all sesson using the same engine
ORMConfiguration config = session.getEngine().getConfiguration(pc);
if (config.autoManageSession()) {
session.flushAll(pc);
session.closeAll(pc);
}
}
pc.getApplicationContext().reinitORM(pc);
ORMUtil.resetEngine(pc, true);
return null;
}
Aggregations