我的Hibernate查询是:
SELECT targets from " + TargetSystem.class.getName()
+ " targets join fetch targets.targetSystemType type"
+ " where type.targetSystemTypeName = '"
+ Constants.Constant_TARGET_SYSTEM_TYPE + "'"
我尝试执行查询时遇到的错误在
之下You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near
'TargetSystem targets join fetch targets.targetSystemType ty' at line 1
注意:targetSystemTypeName是实体中列的Java名称,targetSystemType是外键。
查询执行代码:
Query executeQuery = entityManager.createNativeQuery(query,
TargetSystem.class);
@SuppressWarnings("unchecked")
List<TargetSystem> targetSystems = executeQuery.getResultList();
我无法弄清楚错误是什么