javax.persistence.TemporalType Java Examples

The following examples show how to use javax.persistence.TemporalType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HQLTest.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void test_hql_api_parameter_short_form_example() {
	doInJPA( this::entityManagerFactory, entityManager -> {
		Date timestamp = new Date(  );
		Session session = entityManager.unwrap( Session.class );
		//tag::hql-api-parameter-short-form-example[]
		org.hibernate.query.Query query = session.createQuery(
			"select p " +
			"from Person p " +
			"where p.name like :name " +
			"  and p.createdOn > :timestamp" )
		.setParameter( "name", "J%" )
		.setParameter( "timestamp", timestamp, TemporalType.TIMESTAMP);
		//end::hql-api-parameter-short-form-example[]
	});
}
 
Example #2
Source File: ProcedureCallImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public ProcedureCallImplementor<R> setParameter(int position, Calendar value, TemporalType temporalType) {
	final QueryParameterBinding binding = paramBindings.getBinding( position );
	binding.setBindValue( value, temporalType );
	return this;
}
 
Example #3
Source File: ProcedureCallImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public ProcedureCallImplementor<R> setParameter(int position, Object value, TemporalType temporalType) {
	final QueryParameterBinding binding = paramBindings.getBinding( getParameterMetadata().getQueryParameter( position ) );
	binding.setBindValue( value, temporalType );
	return this;
}
 
Example #4
Source File: CriteriaQueryTypeQueryAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public QueryImplementor<X> setParameter(String name, Calendar calendar, TemporalType temporalType) {
	entityManager.checkOpen( true );
	ExplicitParameterInfo<?> parameterInfo = locateParameterByName( name );
	parameterInfo.validateCalendarBind();
	jpqlQuery.setParameter( name, calendar, temporalType );
	return this;
}
 
Example #5
Source File: AssignmentData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the to date.
*
* @return the to date
*/
  @Basic
  @Column(name = "TO_DATE")
  @Temporal(TemporalType.DATE)
  public Date getToDate() {
      return toDate;
  }
 
Example #6
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a @MapKeyTemporal annotation to the specified annotationList if the specified element
 * contains a map-key-temporal sub-element. This should only be the case for element-collection,
 * many-to-many, or one-to-many associations.
 */
private void getMapKeyTemporal(List<Annotation> annotationList, Element element) {
	Element subelement = element != null ? element.element( "map-key-temporal" ) : null;
	if ( subelement != null ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyTemporal.class );
		TemporalType value = TemporalType.valueOf( subelement.getTextTrim() );
		ad.setValue( "value", value );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example #7
Source File: MybatisParameters.java    From spring-data-mybatis with Apache License 2.0 5 votes vote down vote up
TemporalType getRequiredTemporalType() throws IllegalStateException {

			TemporalType temporalType = getTemporalType();

			if (temporalType != null) {
				return temporalType;
			}

			throw new IllegalStateException(
					String.format("Required temporal type not found for %s!", getType()));
		}
 
Example #8
Source File: CriteriaQueryTypeQueryAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public QueryImplementor<X> setParameter(String name, Date date, TemporalType temporalType) {
	entityManager.checkOpen( true );
	ExplicitParameterInfo<?> parameterInfo = locateParameterByName( name );
	parameterInfo.validateDateBind();
	jpqlQuery.setParameter( name, date, temporalType );
	return this;
}
 
Example #9
Source File: ProcedureCallImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public ProcedureCallImplementor<R> setParameter(Parameter parameter, Date value, TemporalType temporalType) {
	final QueryParameterBinding binding = paramBindings.getBinding( getParameterMetadata().resolve( parameter ) );
	binding.setBindValue( value, temporalType );
	return this;
}
 
Example #10
Source File: DocumentActivityData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the created date.
*
* @return the created date
*/
  @Basic
  @Column(name = "CREATED_DATE")
  @Temporal(TemporalType.DATE)
  public Date getCreatedDate() {
      return createdDate;
  }
 
Example #11
Source File: QueryParameterBindingValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public <P> void validate(Type paramType, Object bind, TemporalType temporalType) {
	if ( bind == null || paramType == null ) {
		// nothing we can check
		return;
	}
	final Class parameterType = paramType.getReturnedClass();
	if ( parameterType == null ) {
		// nothing we can check
		return;
	}

	if ( Collection.class.isInstance( bind ) && !Collection.class.isAssignableFrom( parameterType ) ) {
		// we have a collection passed in where we are expecting a non-collection.
		// 		NOTE : this can happen in Hibernate's notion of "parameter list" binding
		// 		NOTE2 : the case of a collection value and an expected collection (if that can even happen)
		//			will fall through to the main check.
		validateCollectionValuedParameterBinding( parameterType, (Collection) bind, temporalType );
	}
	else if ( bind.getClass().isArray() ) {
		validateArrayValuedParameterBinding( parameterType, bind, temporalType );
	}
	else {
		if ( !isValidBindValue( parameterType, bind, temporalType ) ) {
			throw new IllegalArgumentException(
					String.format(
							"Parameter value [%s] did not match expected type [%s (%s)]",
							bind,
							parameterType.getName(),
							extractName( temporalType )
					)
			);
		}
	}
}
 
Example #12
Source File: MybatisParameters.java    From spring-data-mybatis with Apache License 2.0 5 votes vote down vote up
@Nullable
TemporalType getTemporalType() {

	if (temporalType == null) {
		this.temporalType = annotation == null ? null : annotation.value();
	}

	return this.temporalType;
}
 
Example #13
Source File: ProcedureCallImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public ProcedureCallImplementor<R> setParameter(String name, Calendar value, TemporalType temporalType) {
	final QueryParameterBinding binding = paramBindings.getBinding( name );
	binding.setBindValue( value, temporalType );
	return this;
}
 
Example #14
Source File: AbstractProducedQuery.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public QueryImplementor setParameter(String name, Date value, TemporalType temporalType) {
	getProducer().checkOpen();
	getQueryParameterBindings().getBinding( name ).setBindValue( value, temporalType );
	return this;
}
 
Example #15
Source File: ProcedureCallImplementor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
ProcedureCallImplementor<R> setParameter(int position, Calendar value, TemporalType temporalType);
 
Example #16
Source File: NativeQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
NativeQuery<T> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType);
 
Example #17
Source File: User.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "birthDate", nullable = false, length = 10)
public Date getBirthDate() {
	return this.birthDate;
}
 
Example #18
Source File: AbstractProducedQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QueryImplementor<R> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType) {
	locateBinding( param ).setBindValue( value, temporalType );
	return this;
}
 
Example #19
Source File: VersionTable.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "version_date")
public Date getVersionDate() {
    return this.versionDate;
}
 
Example #20
Source File: NativeQueryImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public NativeQueryImplementor<T> setParameter(int position, OffsetDateTime value, TemporalType temporalType) {
	super.setParameter( position, value, temporalType );
	return this;
}
 
Example #21
Source File: Team.java    From TinyMooc with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "APPLY_DATE", length = 19)
public Date getApplyDate() {
    return this.applyDate;
}
 
Example #22
Source File: Invoice.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "date", nullable = false, length = 10)
public Date getDate() {
	return this.date;
}
 
Example #23
Source File: AbstractProducedQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public QueryImplementor setParameter(int position, Object value, TemporalType temporalType) {
	getQueryParameterBindings().getBinding( position ).setBindValue( value, temporalType );
	return this;
}
 
Example #24
Source File: SQLQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
NativeQuery<T> setParameter(int position, Date value, TemporalType temporalType);
 
Example #25
Source File: SQLQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
NativeQuery<T> setParameter(int position, Calendar value, TemporalType temporalType);
 
Example #26
Source File: NativeQueryImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public NativeQueryImplementor<T> setParameter(int position, Date value, TemporalType temporalType) {
	super.setParameter( position, value, temporalType );
	return this;
}
 
Example #27
Source File: SQLQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
NativeQuery<T> setParameter(String name, Calendar value, TemporalType temporalType);
 
Example #28
Source File: Catalog.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "expiry", nullable = false, length = 10)
public Date getExpiry() {
	return this.expiry;
}
 
Example #29
Source File: CfsFeedback.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "date", nullable = false, length = 10)
public Date getDate() {
	return this.date;
}
 
Example #30
Source File: NativeQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
NativeQuery<T> setParameter(Parameter<Date> param, Date value, TemporalType temporalType);