本文整理了Java中org.apache.openjpa.kernel.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:org.apache.openjpa.kernel.Query
类名称:Query
[英]OpenJPA query interface.
[中]OpenJPA查询接口。
代码示例来源:origin: org.apache.openjpa/openjpa-all
/**
* Initialize this instance from the values held in the
* specified {@link Query}.
*/
public void setFrom(Query query) {
_language = query.getLanguage();
_candidate = query.getCandidateType();
_res = query.getResultType();
_query = query.getQueryString();
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
/**
* Return a key for the given query, or null if it is not cacheable.
*/
public static QueryKey newInstance(Query q, Object[] args) {
// compile to make sure info encoded in query string is available
// via API calls (candidate class, result class, etc)
q.compile();
return newInstance(q, false, args, q.getCandidateType(),
q.hasSubclasses(), q.getStartRange(), q.getEndRange(), null);
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
public Broker getBroker() {
try {
return _query.getBroker();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-jdbc
/**
* Pours the post-compilation state held by this receiver to the given
* query.
*/
public void setInto(Query q) {
q.setQuery(_id);
q.setCandidateType(_candidate, _subclasses);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
/**
* Set query template information into the given concrete
* query instance. However, the language, query string, and
* candidate class are assumed to be declared in the query
* instantiation, and hints are not transferred.
*/
public void setInto(Query query) {
if (_candidate != null)
query.setCandidateType(_candidate, true);
if (!StringUtils.isEmpty(_query))
query.setQuery(_query);
if (_res != null)
query.setResultType(_res);
if (_readOnly != null)
query.setReadOnly(_readOnly.booleanValue());
if (_resultSetMappingName != null)
query.setResultMapping(null, _resultSetMappingName);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
/**
* Constructor; supply factory exception translator and delegate.
*
* @param em The EntityManager which created this query
* @param ret Exception translator for this query
* @param query The underlying "kernel" query.
*/
public QueryImpl(EntityManagerImpl em, RuntimeExceptionTranslator ret, org.apache.openjpa.kernel.Query query,
QueryMetaData qmd) {
super(qmd, em);
_query = new DelegatingQuery(query, ret);
_lock = new ReentrantLock();
if(query.getLanguage() == QueryLanguages.LANG_SQL) {
_convertPositionalParams = false;
}
else {
Compatibility compat = query.getStoreContext().getConfiguration().getCompatibilityInstance();
_convertPositionalParams = compat.getConvertPositionalParametersToNamed();
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
/**
* Ignores this query from PreparedQueryCache by recreating the original
* query if it has been cached.
*/
void ignorePreparedQuery() {
PreparedQuery cached = _em.getPreparedQuery(_id);
if (cached == null)
return;
Broker broker = _em.getBroker();
// Critical assumption: Only JPQL queries are cached and more
// importantly, the identifier of the prepared query is the original
// JPQL String
String JPQL = JPQLParser.LANG_JPQL;
String jpql = _id;
org.apache.openjpa.kernel.Query newQuery = broker.newQuery(JPQL, jpql);
newQuery.getFetchConfiguration().copy(_query.getFetchConfiguration());
newQuery.compile();
_query = new DelegatingQuery(newQuery, _em.getExceptionTranslator());
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
public String getLanguage() {
try {
return _query.getLanguage();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public void setResultMapping(Class scope, String name) {
try {
_query.setResultMapping(scope, name);
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
public void setCandidateType(Class cls, boolean subs) {
try {
_query.setCandidateType(cls, subs);
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel
public Class getCandidateType() {
try {
return _query.getCandidateType();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa
public FetchConfiguration getFetchConfiguration() {
try {
return _query.getFetchConfiguration();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
public boolean setQuery(Object query) {
try {
return _query.setQuery(query);
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
public StoreContext getStoreContext() {
try {
return _query.getStoreContext();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public boolean hasSubclasses() {
try {
return _query.hasSubclasses();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel
public void compile() {
try {
_query.compile();
} catch (RuntimeException re) {
throw translate(re);
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel
/**
* Set query template information into the given concrete
* query instance. However, the language, query string, and
* candidate class are assumed to be declared in the query
* instantiation, and hints are not transferred.
*/
public void setInto(Query query) {
if (_candidate != null)
query.setCandidateType(_candidate, true);
if (!StringUtils.isEmpty(_query))
query.setQuery(_query);
if (_res != null)
query.setResultType(_res);
if (_readOnly != null)
query.setReadOnly(_readOnly.booleanValue());
if (_resultSetMappingName != null)
query.setResultMapping(null, _resultSetMappingName);
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
/**
* Constructor; supply factory exception translator and delegate.
*
* @param em The EntityManager which created this query
* @param ret Exception translator for this query
* @param query The underlying "kernel" query.
*/
public QueryImpl(EntityManagerImpl em, RuntimeExceptionTranslator ret, org.apache.openjpa.kernel.Query query,
QueryMetaData qmd) {
super(qmd, em);
_query = new DelegatingQuery(query, ret);
_lock = new ReentrantLock();
if(query.getLanguage() == QueryLanguages.LANG_SQL) {
_convertPositionalParams = false;
}
else {
Compatibility compat = query.getStoreContext().getConfiguration().getCompatibilityInstance();
_convertPositionalParams = compat.getConvertPositionalParametersToNamed();
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-jdbc
/**
* Pours the post-compilation state held by this receiver to the given
* query.
*/
public void setInto(Query q) {
q.setQuery(_id);
q.setCandidateType(_candidate, _subclasses);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence
/**
* Ignores this query from PreparedQueryCache by recreating the original
* query if it has been cached.
*/
void ignorePreparedQuery() {
PreparedQuery cached = _em.getPreparedQuery(_id);
if (cached == null)
return;
Broker broker = _em.getBroker();
// Critical assumption: Only JPQL queries are cached and more
// importantly, the identifier of the prepared query is the original
// JPQL String
String JPQL = JPQLParser.LANG_JPQL;
String jpql = _id;
org.apache.openjpa.kernel.Query newQuery = broker.newQuery(JPQL, jpql);
newQuery.getFetchConfiguration().copy(_query.getFetchConfiguration());
newQuery.compile();
_query = new DelegatingQuery(newQuery, _em.getExceptionTranslator());
}
内容来源于网络,如有侵权,请联系作者删除!