Tabnine Logo
Query
Code IndexAdd Tabnine to your IDE (free)

How to use
Query
in
leap.orm.query

Best Java code snippets using leap.orm.query.Query (Showing top 20 results out of 315)

origin: org.leapframework/jmms-core

public List<Record> queryList(String sql, Map<String, Object> params) {
  return createQuery(sql, params).list();
}
origin: org.leapframework/leap-orm

/**
 * Returns true if the result has records, or returns false if no records.
 */
default boolean exists() {
  return firstOrNull() != null;
}

origin: org.leapframework/leap-orm

/**
 * Sets the single arg as params.
 */
default Query<T> param(Object arg) {
  return params(new Object[]{arg});
}

origin: org.leapframework/leap-websecurity

@Override
public UserDetails loadUserDetailsById(Object userId) {
  return lazyDao.get()
       .createNamedQuery(SQL_KEY_FIND_USER_DETAILS_BY_ID, SimpleUserDetails.class)
       .param(SQL_PARAM_USER_ID, userId)
       .singleOrNull();
}
origin: org.leapframework/leap-webapi

@Override
public Object apply(ActionParams params) {
  Map<String,Object> map = params.toMap();
  Object result;
  if(command.getMetadata().isSelect()) {
    //todo: page query, total count
    Query query = dao.createQuery(command).params(map);
    if(null != returnType) {
      if(returnType.isSimpleType()) {
        result = Converts.convert(query.scalarValueOrNull(), returnType.asSimpleType().getJavaType());
      }else if(returnType.isCollectionType() && returnType.asCollectionType().getElementType().isSimpleType()) {
        result = query.scalars().list(returnType.asCollectionType().getElementType().asSimpleType().getJavaType());
      }else {
        result = query.list();
      }
    }else {
      result = query.list();
    }
  }else{
    //todo: the return type must be simple type
    result = dao.executeUpdate(command, map);
    if(null != returnType) {
      result = Converts.convert(result, returnType.asSimpleType().getJavaType());
    }
  }
  return ApiResponse.of(result);
}
origin: org.leapframework/leap-oauth2-server

@Override
public AuthzSSOSession loadSessionById(String id) {
  AuthzSSOSessionEntity session = null;
  if(null != loadSessionByIdCommand) {
    session = dao.createQuery(AuthzSSOSessionEntity.class, loadSessionByIdCommand).singleOrNull();
  }else{
    session = dao.createCriteriaQuery(AuthzSSOSessionEntity.class)
        .where("id = ? and expiration > ?", new Object[]{id, new Date()})
        .singleOrNull();
  }
  if(null == session) {
    return null;
  }
  return createSessionFromEntity(session);
}
origin: org.leapframework/leap-orm

/**
 * Returns the scalar value or <code>null</code> if n o records returned.
 *
 * @throws TooManyRecordsException if two or more records returned.
 */
default <T> T scalarValueOrNull() throws TooManyRecordsException {
  Scalar scalar = scalarOrNull();
  return null == scalar ? null : (T)scalar.get();
}
origin: org.leapframework/leap-orm

@Override
public List<T> list() {
  if(null == result) {
    result = query.result(page);
  }
  return result.list();
}
origin: org.leapframework/jmms-core

  public List<Object> queryScalars(String sql, Map<String, Object> params) {
    return createQuery(sql, params).scalars().list();
  }
}
origin: org.leapframework/leap-oauth2-server

@Override
public AuthzSSOSession loadSessionByToken(String username, String token) {
  AuthzSSOSessionEntity session = null;
  if(null != loadSessionByTokenCommand) {
    session = dao.createQuery(AuthzSSOSessionEntity.class, loadSessionByTokenCommand).singleOrNull();
  }else{
    session = dao.createCriteriaQuery(AuthzSSOSessionEntity.class)
           .where("token = ? and user_name = ? and expiration > ?", new Object[]{token, username, new Date()})
           .firstOrNull();
  }
  if(null == session) {
    return null;
  }
  return createSessionFromEntity(session);
}
origin: org.leapframework/leap-websecurity

@Override
public UserDetails loadUserDetailsByLoginName(String username) {
  return lazyDao.get()
      .createNamedQuery(SQL_KEY_FIND_USER_DETAILS_BY_LOGIN_NAME, SimpleUserDetails.class)
      .param(SQL_PARAM_LOGIN_NAME, username)
      .singleOrNull();
}
origin: org.leapframework/leap-orm

/**
 * Returns the scalar value or <code>null</code> if n o records returned.
 *
 * @throws TooManyRecordsException if two or more records returned.
 */
default <T> T scalarValueOrNull(Class<T> type) throws TooManyRecordsException {
  Scalar scalar = scalarOrNull();
  return null == scalar ? null : scalar.get(type);
}

origin: org.leapframework/jmms-core

public QueryResult<Record> query(String sql, Map<String, Object> params) {
  return createQuery(sql, params).result();
}
origin: org.leapframework/leap-orm

/**
 * Sets a {@link ArrayParams} for jdbc placeholders in this query.
 */
default Query<T> params(Object[] args) {
  return params(new ArrayParams(args));
}

origin: org.leapframework/leap-oauth2-server

@Override
public List<AuthzSSOLogin> loadLoginsInSession(AuthzSSOSession session) {
  List<AuthzSSOLoginEntity> entities = null;
  if(null != loadLoginsInSessionCommand) {
    entities = dao.createQuery(AuthzSSOLoginEntity.class, loadLoginsInSessionCommand).list();
  }else{
    entities = dao.createCriteriaQuery(AuthzSSOLoginEntity.class).where("session_id = ?", session.getId()).list();
  }
  List<AuthzSSOLogin> logins = new ArrayList<>();
  for(AuthzSSOLoginEntity entity : entities) {
    logins.add(createLoginFromEntity(entity));
  }
  return logins;
}
origin: org.leapframework/leap-oauth2

protected AuthzClientEntity loadAuthzClientEntity(String clientId){
  AuthzClientEntity entity;
  if(null == loadClientCommand) {
    entity = dao.findOrNull(AuthzClientEntity.class, clientId);
  }else{
    entity = dao.createQuery(AuthzClientEntity.class, loadClientCommand).firstOrNull();
  }
  return entity;
}
origin: org.leapframework/leap-oauth2

@Override
public AuthzSSOSession loadSessionByToken(String username, String token) {
  AuthzSSOSessionEntity session = null;
  if(null != loadSessionByTokenCommand) {
    session = dao.createQuery(AuthzSSOSessionEntity.class, loadSessionByTokenCommand).singleOrNull();
  }else{
    session = dao.createCriteriaQuery(AuthzSSOSessionEntity.class)
           .where("token = ? and user_name = ? and expiration > ?", new Object[]{token, username, new Date()})
           .firstOrNull();
  }
  if(null == session) {
    return null;
  }
  return createSessionFromEntity(session);
}
origin: org.leapframework/jmms-core

public Double queryDouble(String sql, Map<String, Object> params) {
  return createQuery(sql, params).scalarOrNull().get(Double.class);
}
origin: org.leapframework/leap-orm

@Override
public T single() throws EmptyRecordsException, TooManyRecordsException {
  return limit(2).result().single();
}
origin: org.leapframework/leap-orm

@Override
public Query<Record> createSqlQuery(String sql, Object... args) {
  return createSqlQuery(sql).params(args);
}
leap.orm.queryQuery

Most used methods

  • list
    Executes this query and return all the rows as a immutable List object. Returns a empty immutable Li
  • firstOrNull
    Executes this query and return the first row. Returns null if no result returned.
  • params
    Sets a ArrayParams for jdbc placeholders in this query.
  • singleOrNull
    Executes this query and return the first row. Returns null if no result returned.
  • result
    Executes this query and return the query result.
  • scalarOrNull
    Returns the Scalar value in this query result or null if no records returned.
  • scalars
    Returns all the scalar values of the first column in this query result.
  • count
    Executes a count(*) query and returns the total count of records.
  • pageResult
  • param
  • scalar
    Returns the Scalar value in this query result.
  • scalarValueOrNull
    Returns the scalar value or null if n o records returned.
  • scalar,
  • scalarValueOrNull

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • putExtra (Intent)
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now