| Method from org.hibernate.ejb.QueryImpl Detail: |
public int executeUpdate() {
try {
if ( ! em.isTransactionInProgress() ) {
em.throwPersistenceException( new TransactionRequiredException( "Executing an update/delete query" ) );
return 0;
}
return query.executeUpdate();
}
catch (QueryExecutionRequestException he) {
throw new IllegalStateException(he);
}
catch( TypeMismatchException e ) {
throw new IllegalArgumentException(e);
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return 0;
}
}
|
public Query getHibernateQuery() {
return query;
}
|
public List getResultList() {
try {
return query.list();
}
catch (QueryExecutionRequestException he) {
throw new IllegalStateException(he);
}
catch( TypeMismatchException e ) {
throw new IllegalArgumentException(e);
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
|
public Object getSingleResult() {
try {
List result = query.list();
if ( result.size() == 0 ) {
em.throwPersistenceException( new NoResultException( "No entity found for query" ) );
}
else if ( result.size() > 1 ) {
Set uniqueResult = new HashSet(result);
if ( uniqueResult.size() > 1 ) {
em.throwPersistenceException( new NonUniqueResultException( "result returns " + uniqueResult.size() + " elements") );
}
else {
return uniqueResult.iterator().next();
}
}
else {
return result.get(0);
}
return null; //should never happen
}
catch (QueryExecutionRequestException he) {
throw new IllegalStateException(he);
}
catch( TypeMismatchException e ) {
throw new IllegalArgumentException(e);
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
|
public Query setFirstResult(int firstResult) {
if ( firstResult < 0 ) {
throw new IllegalArgumentException(
"Negative ("
+ firstResult
+ ") parameter passed in to setFirstResult"
);
}
query.setFirstResult( firstResult );
return this;
}
|
public Query setFlushMode(FlushModeType flushMode) {
if ( flushMode == FlushModeType.AUTO ) {
query.setFlushMode( FlushMode.AUTO );
}
else if ( flushMode == FlushModeType.COMMIT ) {
query.setFlushMode( FlushMode.COMMIT );
}
return this;
}
|
public Query setHint(String hintName,
Object value) {
try {
if ( "org.hibernate.timeout".equals( hintName ) ) {
query.setTimeout( (Integer) value );
}
else if ( "org.hibernate.comment".equals( hintName ) ) {
query.setComment( (String) value );
}
else if ( "org.hibernate.fetchSize".equals( hintName ) ) {
query.setFetchSize( (Integer) value );
}
else if ( "org.hibernate.cacheRegion".equals( hintName ) ) {
query.setCacheRegion( (String) value );
}
else if ( "org.hibernate.cacheable".equals( hintName ) ) {
query.setCacheable( (Boolean) value );
}
else if ( "org.hibernate.readOnly".equals( hintName ) ) {
query.setReadOnly( (Boolean) value );
}
else if ( "org.hibernate.cacheMode".equals( hintName ) ) {
query.setCacheMode( (CacheMode) value );
}
else if ( "org.hibernate.flushMode".equals( hintName ) ) {
query.setFlushMode( ConfigurationHelper.getFlushMode( value ) );
}
//TODO:
/*else if ( "org.hibernate.lockMode".equals( hintName ) ) {
query.setLockMode( alias, lockMode );
}*/
}
catch (ClassCastException e) {
throw new IllegalArgumentException( "Value for hint" );
}
return this;
}
|
public Query setMaxResults(int maxResult) {
if ( maxResult < 0 ) {
throw new IllegalArgumentException(
"Negative ("
+ maxResult
+ ") parameter passed in to setMaxResults"
);
}
query.setMaxResults( maxResult );
return this;
}
|
public Query setParameter(String name,
Object value) {
try {
if ( value instanceof Collection ) {
query.setParameterList( name, (Collection) value );
}
else {
query.setParameter( name, value );
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
|
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;
}
}
|
public Query setParameter(String name,
Date value,
TemporalType temporalType) {
try {
if ( temporalType == DATE ) {
query.setDate( name, value );
}
else if ( temporalType == TIME ) {
query.setTime( name, value );
}
else if ( temporalType == TIMESTAMP ) {
query.setTimestamp( name, value );
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
|
public Query 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 );
}
return this;
}
catch (QueryParameterException e) {
throw new IllegalArgumentException( e );
}
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
}
}
|
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;
}
}
|
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;
}
}
|