Caused by: org.h2.jdbc.JdbcSQLException: Function "DEVICE_LOCATION_LOG" not found; SQL statement:
select device.serialNumber, device.manufacturerDeviceId, cdl.locationReference.resourceBasePath, cdl.locationReference.tenant, cdl.locationReference.id
from device
left join device_location_log (select locationLogEntry
from device_location_log locationLogEntry
where (locationLogEntry.begin is null or not locationLogEntry.begin > ?) and not (locationLogEntry.end is null or locationLogEntry.end < ?)) as cdl
on cdl.device = device
where cdl.locationReference.resourceBasePath = ? and cdl.locationReference.tenant = ? and cdl.locationReference.id = ? [90022-191]@Test public void quickTest() { final H2Templates sqlTemplates = new H2Templates();
// Define the sub query. final Instant currentTimestamp = now(getInstanceUTC()).toInstant(); final JPASQLQuery<LocationLogEntry> currentDeviceLocationQuery = new JPASQLQuery<>(getEntityManager(), sqlTemplates)
.select(locationLogEntry) .from(locationLogEntry) .where(locationLogEntry.begin.isNull() .or(locationLogEntry.begin.after(currentTimestamp) .not()), locationLogEntry.end.isNull() .or(locationLogEntry.end.before(currentTimestamp)) .not());
// Execute the main query that uses the sub query. final QLocationLogEntry currentDeviceLocation = new QLocationLogEntry("cdl"); final List<Tuple> results = new JPASQLQuery<>(getEntityManager(), sqlTemplates).select(device.serialNumber, device.manufacturerDeviceId, currentDeviceLocation.locationReference.resourceBasePath, currentDeviceLocation.locationReference.tenant, .from(device) .leftJoin(currentDeviceLocationQuery, currentDeviceLocation) .on(currentDeviceLocation.device.eq(device)) .where(currentDeviceLocation.locationReference.resourceBasePath.eq(Location.RESOURCE_BASE_PATH), currentDeviceLocation.locationReference.id.eq(Long.valueOf(6))) .fetch(); LOGGER.debug("Results: " + results); }