use of org.hibernate.query.spi.QueryParameterBindings in project hibernate-orm by hibernate.
the class ParameterTests method testNarrowingTemporalPrecision.
@Test
public void testNarrowingTemporalPrecision() {
try (Session session = sessionFactory().openSession()) {
final Query query = session.createQuery("select p.id from Person p where p.dob between :start and :end");
query.setParameter("start", Instant.now().minus(7, ChronoUnit.DAYS), TemporalType.DATE);
query.setParameter("end", Instant.now().plus(7, ChronoUnit.DAYS), TemporalType.DATE);
final QueryParameterBindings bindings = ((DomainQueryExecutionContext) query).getQueryParameterBindings();
final QueryParameterBinding<?> startBinding = bindings.getBinding("start");
assertThat(startBinding.getExplicitTemporalPrecision(), equalTo(TemporalType.DATE));
final QueryParameterBinding<?> endBinding = bindings.getBinding("end");
assertThat(endBinding.getExplicitTemporalPrecision(), equalTo(TemporalType.DATE));
}
}
use of org.hibernate.query.spi.QueryParameterBindings in project hibernate-orm by hibernate.
the class ParameterTests method testWideningTemporalPrecision.
@Test
public void testWideningTemporalPrecision() {
try (Session session = sessionFactory().openSession()) {
final Query query = session.createQuery("select p.id from Person p where p.anniversary between :start and :end");
query.setParameter("start", Date.from(Instant.now().minus(7, ChronoUnit.DAYS)), TemporalType.TIMESTAMP);
query.setParameter("end", Date.from(Instant.now().plus(7, ChronoUnit.DAYS)), TemporalType.TIMESTAMP);
final QueryParameterBindings bindings = ((DomainQueryExecutionContext) query).getQueryParameterBindings();
final QueryParameterBinding<?> startBinding = bindings.getBinding("start");
assertThat(startBinding.getExplicitTemporalPrecision(), equalTo(TemporalType.TIMESTAMP));
final QueryParameterBinding<?> endBinding = bindings.getBinding("end");
assertThat(endBinding.getExplicitTemporalPrecision(), equalTo(TemporalType.TIMESTAMP));
}
}
Aggregations