Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPQL和ON子句基本子查询_Java_Mysql_Hibernate_Jpa_Spring Data - Fatal编程技术网

Java JPQL和ON子句基本子查询

Java JPQL和ON子句基本子查询,java,mysql,hibernate,jpa,spring-data,Java,Mysql,Hibernate,Jpa,Spring Data,在MySQL中,这是可行的,我希望与hibernate实现等效: Select * from A a left join B b on a.id=b.id AND b.lenght=20 有OneToMany():A类包含列表b 在hibernate的帮助下,我陷入了这样的困境: //the ON clause comes from the mapping's join columns and is handled automatically @Query(Select a from A a

在MySQL中,这是可行的,我希望与hibernate实现等效:

Select * from A a left join B b on a.id=b.id AND b.lenght=20
OneToMany()
A类
包含
列表b

在hibernate的帮助下,我陷入了这样的困境:

//the ON clause comes from the mapping's join columns and is handled automatically 
@Query(Select a from A a left join a.b c) 
但是我不知道如何添加这个部分
和b.lenght=20


是否要用JPA将其转换为JPQL?

您可以使用with关键字在join子句中添加您的条件

Select a from A a left join a.b with b.lenght = 20
。。。假设
lenght
是B中的一个字段,而不是长度函数


[

是的,lenght是BWITH中一个无效JPQL的字段。建议您在回答中明确指出,当有JPA标准的“ON”子句可用时,用户正在放弃供应商独立性……您的意思是“LEFT JOIN a.b ON b.length=20”?您会在JPA 2.1规范中发现JPA使用JPQL,而不是“HQL”JPQL和“HQL”它们几乎是一样的。差别很小。一个是便携的,另一个不是;关键的差别是