Remove some unnecessary code duplications in AbstractSelectionQuery and AbstractQuery

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2023-04-06 17:30:53 +02:00 committed by Jan Schatteman
parent 1de4a76008
commit 53f752d138
2 changed files with 9 additions and 27 deletions

View File

@ -130,27 +130,18 @@ public abstract class AbstractQuery<R>
@Override
public int getMaxResults() {
getSession().checkOpen();
return getQueryOptions().getLimit().getMaxRowsJpa();
return super.getMaxResults();
}
@Override
public QueryImplementor<R> setMaxResults(int maxResult) {
if ( maxResult < 0 ) {
throw new IllegalArgumentException( "max-results cannot be negative" );
}
getSession().checkOpen();
getQueryOptions().getLimit().setMaxRows( maxResult );
super.setMaxResults( maxResult );
return this;
}
@Override
public int getFirstResult() {
getSession().checkOpen();
return getQueryOptions().getLimit().getFirstRowJpa();
return super.getFirstResult();
}
@Override
@ -256,7 +247,7 @@ public abstract class AbstractQuery<R>
@Override
public LockModeType getLockMode() {
getSession().checkOpen( false );
return LockModeTypeHelper.getLockModeType( getQueryOptions().getLockOptions().getLockMode() );
return super.getLockMode();
}
@Override
@ -274,18 +265,18 @@ public abstract class AbstractQuery<R>
@Override
public QueryImplementor<R> setLockMode(LockModeType lockModeType) {
getSession().checkOpen();
getQueryOptions().getLockOptions().setLockMode( LockModeTypeHelper.getLockMode( lockModeType ) );
super.setHibernateLockMode( LockModeTypeHelper.getLockMode( lockModeType ) );
return this;
}
@Override
public String getComment() {
return getQueryOptions().getComment();
return super.getComment();
}
@Override
public QueryImplementor<R> setComment(String comment) {
getQueryOptions().setComment( comment );
super.setComment( comment );
return this;
}
@ -365,8 +356,7 @@ public abstract class AbstractQuery<R>
@Override
@SuppressWarnings( {"unchecked", "rawtypes"} )
public Set<Parameter<?>> getParameters() {
getSession().checkOpen( false );
return (Set) getParameterMetadata().getRegistrations();
return super.getParameters();
}
@Override
@ -518,7 +508,6 @@ public abstract class AbstractQuery<R>
@Override
public <P> QueryImplementor<R> setParameterList(int position, Collection<? extends P> values, Class<P> javaTypeClass) {
super.setParameterList( position, values, javaTypeClass );
return this;
}

View File

@ -541,14 +541,7 @@ public abstract class AbstractSelectionQuery<R>
@Override
public SelectionQuery<R> setMaxResults(int maxResult) {
if ( maxResult < 0 ) {
throw new IllegalArgumentException( "max-results cannot be negative" );
}
getSession().checkOpen();
getQueryOptions().getLimit().setMaxRows( maxResult );
super.applyMaxResults( maxResult );
return this;
}