本文整理了Java中leap.orm.query.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:leap.orm.query.Query
类名称:Query
暂无
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!