/**
* HQL version of the query
*/
private <T extends RouteLeg> RouteLeg findRouteLegByFromToHQL(GeoCoord from, GeoCoord to, Class clazz) throws DatabaseException {
final String bikeQuery = "SELECT leg from BikeLeg leg WHERE leg.from = :fromGeo AND leg.to = :toGeo";
final String carQuery = "SELECT leg from CarLeg leg WHERE leg.from = :fromGeo AND leg.to = :toGeo";
try {
TypedQuery<? extends RouteLeg> query;
if (clazz == BikeLeg.class) {
query = entityManager.createQuery(bikeQuery, BikeLeg.class);
} else {
query = entityManager.createQuery(carQuery, CarLeg.class);
}
List<? extends RouteLeg> resultList = query.setParameter("fromGeo", from)
.setParameter("toGeo", to)
.getResultList();
return extractOne(resultList);
} catch (IndexOutOfBoundsException e) {
throw new DatabaseException("Could not find entity " + clazz + " for coordinates " + from + " -> " + to);
}
}
RouteLegRepositoryImpl.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:xsharing-services-router
作者:
评论列表
文章目录