我正在寻找如何将以下查询(SQL)转换为查询JPQL;
SELECT * FROM equipements eq
LEFT JOIN check_lists checks
ON eq.id_equipements = checks.equipements_id
LEFT JOIN responses_check_lists resp
ON checks.id_check_lists = resp.check_lists_id
AND resp.missions_id = 15
AND eq.id_equipements = 1
ORDER BY checks.id_check_lists
我跟踪了互联网上的文件,但我没有在JPQL中正确转换我的查询。
我知道查询的属性将被类的属性所取代。
我发布这里是为了帮助我转换SQL查询。
编辑1:
@Query(
"SELECT r, checks, eq"
+ " FROM Equipements eq"
+ " LEFT JOIN CheckLists checks "
+ " ON eq.idEquipements = checks.equipements.idEquipements"
+ " LEFT JOIN ResponsesCheckLists r"
+ " ON checks.idCheckLists = r.CheckLts.idCheckLists"
+ " AND r.Respmission.idMission= :idmiss "
+ " AND eq.idEquipements= :idEqp"
+ " ORDER BY checks.idCheckLists ASC"
)
编辑1的错误:
引起:java.lang.IllegalStateException:节点没有数据类型: org.hibernate.hql.internal.ast.tree.IdentNode + - [IDENT] IdentNode: ' R' {originalText = R}
org.hibernate.hql.internal.ast.InvalidPathException:路径无效: ' checks.idCheckLists'
提前谢谢你,
答案 0 :(得分:0)
分析你的SQL而不看实体,你的JPQL可以是这样的:
var engine = SapRot.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, SapRot, null);
var connection = (engine as GuiApplication).OpenConnection(connectionString);
var session = connection.Children.ElementAt(0) as GuiSession;
但是,要像这样,你需要调整实体的映射(实体名称,列名等)。