Package railo.runtime.orm

Examples of railo.runtime.orm.ORMSession


public class ORMReload {
  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.flush(pc);
        session.close(pc);
      }
    }
    pc.getApplicationContext().reinitORM(pc);
    ORMUtil.resetEngine(pc,true);
    return null;
View Full Code Here


import railo.runtime.orm.ORMSession;
import railo.runtime.orm.ORMUtil;

public class ORMGetSession {
  public static Object call(PageContext pc) throws PageException {
    ORMSession session = ORMUtil.getSession(pc);
    return session.getRawSession();
  }
View Full Code Here

import railo.runtime.orm.ORMSession;
import railo.runtime.orm.ORMUtil;

public class ORMFlush {
  public static String call(PageContext pc) throws PageException {
    ORMSession session = ORMUtil.getSession(pc);
    session.flush(pc);
    return null;
  }
View Full Code Here

public class EntityLoad {
 
  public static Object call(PageContext pc, String name) throws PageException {
   
    ORMSession session=ORMUtil.getSession(pc);
    return session.loadAsArray(pc,name,new StructImpl());
  }
View Full Code Here

 
  public static Object call(PageContext pc, String name,Object idOrFilter) throws PageException {
    return call(pc, name, idOrFilter, Boolean.FALSE);
  }
  public static Object call(PageContext pc, String name,Object idOrFilter, Object uniqueOrOptions) throws PageException {
    ORMSession session=ORMUtil.getSession(pc);
   
    // id
    if(Decision.isSimpleValue(idOrFilter)){
      // id,unique
      if(Decision.isCastableToBoolean(uniqueOrOptions)){
        // id,unique=true
        if(Caster.toBooleanValue(uniqueOrOptions))
          return session.load(pc,name, Caster.toString(idOrFilter));
        // id,unique=false
        return session.loadAsArray(pc,name, Caster.toString(idOrFilter));
      }
      else if(Decision.isString(uniqueOrOptions)){
        return session.loadAsArray(pc,name,Caster.toString(idOrFilter),Caster.toString(uniqueOrOptions));
      }
     
      // id,options
      return session.loadAsArray(pc,name,Caster.toString(idOrFilter));
    }
   
    // filter,[unique|sortorder]
    if(Decision.isSimpleValue(uniqueOrOptions)){
      // filter,unique
      if(Decision.isBoolean(uniqueOrOptions)){
        if(Caster.toBooleanValue(uniqueOrOptions))
          return session.load(pc,name,Caster.toStruct(idOrFilter));
        return session.loadAsArray(pc,name,Caster.toStruct(idOrFilter));
      }
      // filter,sortorder
      return session.loadAsArray(pc,name,Caster.toStruct(idOrFilter),(Struct)null,Caster.toString(uniqueOrOptions));
    }
    // filter,options
    return session.loadAsArray(pc,name,Caster.toStruct(idOrFilter),Caster.toStruct(uniqueOrOptions));
  }
View Full Code Here

  }
 
 
 
  public static Object call(PageContext pc, String name,Object filter, Object order, Object options) throws PageException {
    ORMSession session=ORMUtil.getSession(pc);
    return session.loadAsArray(pc,name,Caster.toStruct(filter),Caster.toStruct(options),Caster.toString(order));
  }
View Full Code Here

  public static Object call(PageContext pc,String hql,Object params,Object unique, Object queryOptions) throws PageException {
    return _call(pc,hql,params,Caster.toBooleanValue(unique),Caster.toStruct(queryOptions));
  }
  private static Object _call(PageContext pc,String hql, Object params, boolean unique, Struct queryOptions) throws PageException {
    ORMSession session=ORMUtil.getSession(pc);
    if(params==null)
      return session.executeQuery(pc,hql,new ArrayImpl(),unique,queryOptions);
    else if(Decision.isStruct(params))
      return session.executeQuery(pc,hql,Caster.toStruct(params),unique,queryOptions);
    else if(Decision.isArray(params))
      return session.executeQuery(pc,hql,Caster.toArray(params),unique,queryOptions);
    else if(Decision.isCastableToStruct(params))
      return session.executeQuery(pc,hql,Caster.toStruct(params),unique,queryOptions);
    else if(Decision.isCastableToArray(params))
      return session.executeQuery(pc,hql,Caster.toArray(params),unique,queryOptions);
    else
      throw new FunctionException(pc, "ORMExecuteQuery", 2, "params", "cannot convert the params to a array or a struct");
  }
View Full Code Here

public class ORMEvictEntity {
  public static String call(PageContext pc,String entityName) throws PageException {
    return call(pc, entityName,null);
  }
  public static String call(PageContext pc,String entityName,String primaryKey) throws PageException {
    ORMSession session=ORMUtil.getSession(pc);
    if(StringUtil.isEmpty(primaryKey))session.evictEntity(pc, entityName);
    else session.evictEntity(pc, entityName,primaryKey);
    return null;
  }
View Full Code Here

  public static Object call(PageContext pc, Object sampleEntity) throws PageException {
    return call(pc, sampleEntity, false);
  }
 
  public static Object call(PageContext pc, Object sampleEntity,boolean unique) throws PageException {
    ORMSession session=ORMUtil.getSession(pc);
    if(unique)return session.loadByExample(pc,sampleEntity);
    return session.loadByExampleAsArray(pc,sampleEntity);
  }
View Full Code Here

import railo.runtime.orm.ORMSession;
import railo.runtime.orm.ORMUtil;

public class EntityLoadByPK {
  public static Object call(PageContext pc, String name,String id) throws PageException {
    ORMSession session=ORMUtil.getSession(pc);
    return session.load(pc,name, id);
  }
View Full Code Here

TOP

Related Classes of railo.runtime.orm.ORMSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.