Remove some unnecessary code duplications in AbstractSelectionQuery and AbstractQuery
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
9fabe509f2
commit
1ce0bca179
|
@ -130,27 +130,18 @@ public abstract class AbstractQuery<R>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxResults() {
|
public int getMaxResults() {
|
||||||
getSession().checkOpen();
|
return super.getMaxResults();
|
||||||
return getQueryOptions().getLimit().getMaxRowsJpa();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryImplementor<R> setMaxResults(int maxResult) {
|
public QueryImplementor<R> setMaxResults(int maxResult) {
|
||||||
if ( maxResult < 0 ) {
|
super.setMaxResults( maxResult );
|
||||||
throw new IllegalArgumentException( "max-results cannot be negative" );
|
|
||||||
}
|
|
||||||
|
|
||||||
getSession().checkOpen();
|
|
||||||
|
|
||||||
getQueryOptions().getLimit().setMaxRows( maxResult );
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirstResult() {
|
public int getFirstResult() {
|
||||||
getSession().checkOpen();
|
return super.getFirstResult();
|
||||||
return getQueryOptions().getLimit().getFirstRowJpa();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -256,7 +247,7 @@ public abstract class AbstractQuery<R>
|
||||||
@Override
|
@Override
|
||||||
public LockModeType getLockMode() {
|
public LockModeType getLockMode() {
|
||||||
getSession().checkOpen( false );
|
getSession().checkOpen( false );
|
||||||
return LockModeTypeHelper.getLockModeType( getQueryOptions().getLockOptions().getLockMode() );
|
return super.getLockMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -274,18 +265,18 @@ public abstract class AbstractQuery<R>
|
||||||
@Override
|
@Override
|
||||||
public QueryImplementor<R> setLockMode(LockModeType lockModeType) {
|
public QueryImplementor<R> setLockMode(LockModeType lockModeType) {
|
||||||
getSession().checkOpen();
|
getSession().checkOpen();
|
||||||
getQueryOptions().getLockOptions().setLockMode( LockModeTypeHelper.getLockMode( lockModeType ) );
|
super.setHibernateLockMode( LockModeTypeHelper.getLockMode( lockModeType ) );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getComment() {
|
public String getComment() {
|
||||||
return getQueryOptions().getComment();
|
return super.getComment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryImplementor<R> setComment(String comment) {
|
public QueryImplementor<R> setComment(String comment) {
|
||||||
getQueryOptions().setComment( comment );
|
super.setComment( comment );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,8 +356,7 @@ public abstract class AbstractQuery<R>
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( {"unchecked", "rawtypes"} )
|
@SuppressWarnings( {"unchecked", "rawtypes"} )
|
||||||
public Set<Parameter<?>> getParameters() {
|
public Set<Parameter<?>> getParameters() {
|
||||||
getSession().checkOpen( false );
|
return super.getParameters();
|
||||||
return (Set) getParameterMetadata().getRegistrations();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -518,7 +508,6 @@ public abstract class AbstractQuery<R>
|
||||||
@Override
|
@Override
|
||||||
public <P> QueryImplementor<R> setParameterList(int position, Collection<? extends P> values, Class<P> javaTypeClass) {
|
public <P> QueryImplementor<R> setParameterList(int position, Collection<? extends P> values, Class<P> javaTypeClass) {
|
||||||
super.setParameterList( position, values, javaTypeClass );
|
super.setParameterList( position, values, javaTypeClass );
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -541,14 +541,7 @@ public abstract class AbstractSelectionQuery<R>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SelectionQuery<R> setMaxResults(int maxResult) {
|
public SelectionQuery<R> setMaxResults(int maxResult) {
|
||||||
if ( maxResult < 0 ) {
|
super.applyMaxResults( maxResult );
|
||||||
throw new IllegalArgumentException( "max-results cannot be negative" );
|
|
||||||
}
|
|
||||||
|
|
||||||
getSession().checkOpen();
|
|
||||||
|
|
||||||
getQueryOptions().getLimit().setMaxRows( maxResult );
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue