本文整理了Java中org.hibernate.ejb.QueryImpl
类的一些代码示例,展示了QueryImpl
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryImpl
类的具体详情如下:
包路径:org.hibernate.ejb.QueryImpl
类名称:QueryImpl
[英]Hibernate implementation of both the Query and TypedQuery contracts.
[中]Hibernate实现查询和TypedQuery契约。
代码示例来源:origin: hibernate/hibernate-entitymanager
public Query createQuery(String ejbqlString) {
//adjustFlushMode();
try {
return new QueryImpl( getSession().createQuery( ejbqlString ), this );
}
catch (HibernateException he) {
throwPersistenceException( he );
return null;
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
public TypedQuery<X> setParameter(int position, Object value) {
try {
if ( isJpaPositionalParameter( position ) ) {
this.setParameter( Integer.toString( position ), value );
}
else {
query.setParameter( position - 1, value );
registerParameterBinding( getParameter( position ), value );
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
throw getEntityManager().convert( he );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
public QueryImpl(
org.hibernate.Query query,
AbstractEntityManagerImpl em,
Map<String,Class> namedParameterTypeRedefinitions) {
super( em );
this.query = query;
extractParameterInfo( namedParameterTypeRedefinitions );
}
代码示例来源:origin: hibernate/hibernate-entitymanager
public Query setParameter(int position, Object value) {
try {
if ( isPositionalParameter() ) {
this.setParameter( Integer.toString( position ), value );
}
else {
query.setParameter( position - 1, value );
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
public TypedQuery<X> setParameter(String name, Object value) {
try {
if ( value instanceof Collection ) {
query.setParameterList( name, (Collection) value );
}
else {
query.setParameter( name, value );
}
registerParameterBinding( getParameter( name ), value );
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
throw getEntityManager().convert( he );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
public <T> TypedQuery<X> setParameter(Parameter<T> param, T value) {
if ( ! parameters.contains( param ) ) {
throw new IllegalArgumentException( "Specified parameter was not found in query" );
}
if ( param.getName() != null ) {
// a named param, for not delegate out. Eventually delegate *into* this method...
setParameter( param.getName(), value );
}
else {
setParameter( param.getPosition(), value );
}
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
public Parameter<?> getParameter(int position) {
if ( isJpaPositionalParameter( position ) ) {
return getParameter( Integer.toString( position ) );
}
else {
for ( Parameter parameter : parameters ) {
if ( parameter.getPosition() != null && position == parameter.getPosition() ) {
return parameter;
}
}
throw new IllegalArgumentException( "Unable to locate parameter with position [" + position + "]" );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
@Override
@SuppressWarnings({ "unchecked" })
public TypedQuery<X> setLockMode(javax.persistence.LockModeType lockModeType) {
if (! getEntityManager().isTransactionInProgress()) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
if ( ! canApplyLockModes() ) {
throw new IllegalStateException( "Not a JPAQL/Criteria query" );
}
this.jpaLockMode = lockModeType;
( (org.hibernate.internal.QueryImpl) query ).getLockOptions().setLockMode(
LockModeTypeHelper.getLockMode( lockModeType )
);
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
if ( getSpecifiedMaxResults() != 1 &&
! ( SQLQuery.class.isAssignableFrom( query.getClass() ) ) ) {
mucked = true;
query.setMaxResults( getSpecifiedMaxResults() );
getEntityManager().handlePersistenceException( nre );
throw nre;
if ( uniqueResult.size() > 1 ) {
NonUniqueResultException nure = new NonUniqueResultException( "result returns more than one elements" );
getEntityManager().handlePersistenceException( nure );
throw nure;
throw getEntityManager().convert( he );
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked", "RedundantCast" })
public List<X> getResultList() {
try {
return query.list();
}
catch (QueryExecutionRequestException he) {
throw new IllegalStateException(he);
}
catch( TypeMismatchException e ) {
throw new IllegalArgumentException(e);
}
catch (HibernateException he) {
throw getEntityManager().convert( he );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
public <T> Parameter<T> getParameter(String name, Class<T> type) {
Parameter param = getParameter( name );
if ( param.getParameterType() != null ) {
// we were able to determine the expected type during analysis, so validate it here
throw new IllegalArgumentException(
"Parameter type [" + param.getParameterType().getName() +
"] is not assignment compatible with requested type [" +
type.getName() + "]"
);
}
return param;
}
代码示例来源:origin: org.rhq/rhq-enterprise-server
@Override
public PageList<Alert> findAlertsByCriteria(Subject subject, AlertCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
if (!authorizationManager.isInventoryManager(subject)) {
generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.RESOURCE,
"alertDefinition.resource", subject.getId());
}
Query query = generator.getQuery(entityManager);
if (log.isDebugEnabled()) {
QueryImpl queryImpl = (QueryImpl) query;
PageControl pageControl = CriteriaQueryGenerator.getPageControl(criteria);
log.debug("*Executing JPA query: " + queryImpl.getHibernateQuery().getQueryString() + ", selection=["
+ pageControl.getStartRow() + ".." + (pageControl.getStartRow() + pageControl.getPageSize() - 1)
+ "]...");
}
CriteriaQueryRunner<Alert> queryRunner = new CriteriaQueryRunner<Alert>(criteria, generator, entityManager);
PageList<Alert> alerts = queryRunner.execute();
fetchCollectionFields(alerts);
return alerts;
}
}
代码示例来源:origin: hibernate/hibernate-entitymanager
public Query setParameter(int position, Calendar value, TemporalType temporalType) {
try {
if ( isPositionalParameter() ) {
String name = Integer.toString( position );
this.setParameter( name, value, temporalType );
}
else {
if ( temporalType == DATE ) {
query.setCalendarDate( position - 1, value );
}
else if ( temporalType == TIME ) {
throw new IllegalArgumentException( "not yet implemented" );
}
else if ( temporalType == TIMESTAMP ) {
query.setCalendar( position - 1, value );
}
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
public TypedQuery<X> setParameter(Parameter<Date> param, Date value, TemporalType temporalType) {
if ( ! parameters.contains( param ) ) {
throw new IllegalArgumentException( "Specified parameter was not found in query" );
}
if ( param.getName() != null ) {
// a named param, for not delegate out. Eventually delegate *into* this method...
setParameter( param.getName(), value, temporalType );
}
else {
setParameter( param.getPosition(), value, temporalType );
}
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
public TypedQuery<X> setParameter(String name, Calendar value, TemporalType temporalType) {
try {
if ( temporalType == DATE ) {
query.setCalendarDate( name, value );
}
else if ( temporalType == TIME ) {
throw new IllegalArgumentException( "not yet implemented" );
}
else if ( temporalType == TIMESTAMP ) {
query.setCalendar( name, value );
}
registerParameterBinding( getParameter(name), value );
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
throw getEntityManager().convert( he );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
private SessionFactoryImplementor sfi() {
return (SessionFactoryImplementor) getEntityManager().getFactory().getSessionFactory();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
public <T> Parameter<T> getParameter(int position, Class<T> type) {
Parameter param = getParameter( position );
if ( param.getParameterType() != null ) {
// we were able to determine the expected type during analysis, so validate it here
throw new IllegalArgumentException(
"Parameter type [" + param.getParameterType().getName() +
"] is not assignment compatible with requested type [" +
type.getName() + "]"
);
}
return param;
}
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
public Query createQuery(String ejbqlString) {
//adjustFlushMode();
try {
return new QueryImpl( getSession().createQuery( ejbqlString ), this );
}
catch (HibernateException he) {
throwPersistenceException( he );
return null;
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
/**
* {@inheritDoc}
*/
public TypedQuery<X> setParameter(int position, Calendar value, TemporalType temporalType) {
try {
if ( isJpaPositionalParameter( position ) ) {
String name = Integer.toString( position );
this.setParameter( name, value, temporalType );
}
else {
if ( temporalType == DATE ) {
query.setCalendarDate( position - 1, value );
}
else if ( temporalType == TIME ) {
throw new IllegalArgumentException( "not yet implemented" );
}
else if ( temporalType == TIMESTAMP ) {
query.setCalendar( position - 1, value );
}
registerParameterBinding( getParameter( position ), value );
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
throw getEntityManager().convert( he );
}
}
代码示例来源:origin: hibernate/hibernate-entitymanager
public Query setParameter(int position, Date value, TemporalType temporalType) {
try {
if ( isPositionalParameter() ) {
String name = Integer.toString( position );
this.setParameter( name, value, temporalType );
}
else {
if ( temporalType == DATE ) {
query.setDate( position - 1, value );
}
else if ( temporalType == TIME ) {
query.setTime( position - 1, value );
}
else if ( temporalType == TIMESTAMP ) {
query.setTimestamp( position - 1, value );
}
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!