HHH-10726 - Support for Java 8 date/time types as Query parameters
This commit is contained in:
parent
d44bacedd0
commit
60dd63536e
|
@ -6,6 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.query;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.persistence.FlushModeType;
|
||||
|
@ -50,6 +54,31 @@ public interface Query<R> extends TypedQuery<R>, org.hibernate.Query<R>, BasicQu
|
|||
*/
|
||||
RowSelection getQueryOptions();
|
||||
|
||||
Query<R> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(Parameter<LocalDateTime> param, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(Parameter<ZonedDateTime> param, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(Parameter<OffsetDateTime> param, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(String name, Instant value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(String name, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(String name, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(String name, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(int position, Instant value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(int position, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(int position, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
Query<R> setParameter(int position, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// covariant overrides
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
package org.hibernate.query.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
@ -298,6 +302,78 @@ public abstract class AbstractProducedQuery<R> implements QueryImplementor<R> {
|
|||
return ArrayHelper.toStringArray( getParameterMetadata().getNamedParameterNames() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType) {
|
||||
locateBinding( param ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(Parameter<LocalDateTime> param, LocalDateTime value, TemporalType temporalType) {
|
||||
locateBinding( param ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(Parameter<ZonedDateTime> param, ZonedDateTime value, TemporalType temporalType) {
|
||||
locateBinding( param ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(Parameter<OffsetDateTime> param, OffsetDateTime value, TemporalType temporalType) {
|
||||
locateBinding( param ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(String name, Instant value, TemporalType temporalType) {
|
||||
locateBinding( name ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(String name, LocalDateTime value, TemporalType temporalType) {
|
||||
locateBinding( name ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(String name, ZonedDateTime value, TemporalType temporalType) {
|
||||
locateBinding( name ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(String name, OffsetDateTime value, TemporalType temporalType) {
|
||||
locateBinding( name ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(int position, Instant value, TemporalType temporalType) {
|
||||
locateBinding( position ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(int position, LocalDateTime value, TemporalType temporalType) {
|
||||
locateBinding( position ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(int position, ZonedDateTime value, TemporalType temporalType) {
|
||||
locateBinding( position ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryImplementor<R> setParameter(int position, OffsetDateTime value, TemporalType temporalType) {
|
||||
locateBinding( position ).setBindValue( value, temporalType );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <P> QueryImplementor setParameter(QueryParameter<P> parameter, P value) {
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.query.procedure.spi;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.LockModeType;
|
||||
import javax.persistence.Parameter;
|
||||
import javax.persistence.ParameterMode;
|
||||
import javax.persistence.StoredProcedureQuery;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
|
||||
/**
|
||||
* Defines extended support for JPA-defined stored-procedure execution. This is the one Query form
|
||||
* that still uses wrapping as there are very fundamental differences between Hibernate's
|
||||
* native procedure support and JPA's.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface StoredProcedureQueryImplementor extends StoredProcedureQuery, QueryImplementor<Object> {
|
||||
ProcedureCall getHibernateProcedureCall();
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// covariant overrides
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setHint(String hintName, Object value);
|
||||
|
||||
@Override
|
||||
<T> StoredProcedureQueryImplementor setParameter(Parameter<T> param, T value);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(String name, Object value);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(String name, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(String name, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(int position, Object value);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(int position, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setParameter(int position, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setFlushMode(FlushModeType flushMode);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor registerStoredProcedureParameter(int position, Class type, ParameterMode mode);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setMaxResults(int maxResult);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setFirstResult(int startPosition);
|
||||
|
||||
@Override
|
||||
StoredProcedureQueryImplementor setLockMode(LockModeType lockMode);
|
||||
}
|
Loading…
Reference in New Issue