Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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
未能通过Spring JPA数据在查询注释中连接三个实体模型_Spring_Hibernate_Jpa - Fatal编程技术网

未能通过Spring JPA数据在查询注释中连接三个实体模型

未能通过Spring JPA数据在查询注释中连接三个实体模型,spring,hibernate,jpa,Spring,Hibernate,Jpa,在JSF2.x应用程序中,我有三个表和映射JPA实体模型,如下所示 Foo Foo.java Bar Bar.java Zoo Zoo.java 在实体模型上下文中,Foo与Bar和Zoo都有@oneToMany关系。在本机sql中,我能够加入其中三个,它们工作得很好 select f.*, b.*, z.* from Foo f inner join Bar b on f.foo_id = b.foo_id inner join Zoo z

在JSF2.x应用程序中,我有三个表和映射JPA实体模型,如下所示

Foo   Foo.java
Bar   Bar.java
Zoo   Zoo.java
在实体模型上下文中,Foo与Bar和Zoo都有@oneToMany关系。在本机sql中,我能够加入其中三个,它们工作得很好

select f.*, b.*, z.*
from Foo f
  inner join Bar b
    on f.foo_id = b.foo_id
      inner join Zoo z
        on z.foo_id = b.foo_id
          where b.name = 'barName' and z.type = 'zooType";
我试图通过Spring JPA数据翻译查询注释中的本机sql,但是我一直得到org.hibernate.hgql.internal.ast.QuerySyntaxException:意外标记

有人能亲切地指出我做错了什么吗?我尝试了“一个内部连接”,但我得到了同样的例外

@Query("select f from Foo f inner join f.bars b inner join f.zoos z " +
        "where b.name = ?1 " + 
        "where z.type = ?2")
List<Foo> findFoo(String name, String type);
@Query(“从Foo f内部连接f.bar b内部连接f.zoos z中选择f”+
“其中b.name=?1”+
“其中z.type=?2”)
列表findFoo(字符串名称、字符串类型);

这是因为,在@Query块中写两个where,也许应该使用

 @Query("select f from Foo f inner join f.bars b inner join f.zoos z " +
 "where b.name = ?1 " + 
 "and z.type = ?2")
List<Foo> findFoo(String name, String type);
@Query(“从Foo f内部连接f.bar b内部连接f.zoos z中选择f”+
“其中b.name=?1”+
“和z.type=?2”)
列表findFoo(字符串名称、字符串类型);
相反:)

谢谢!将“where”替换为“和”fixed it.:-)