Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.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 在HQL查询中从依赖实体中选择属性_Java_Hibernate_Hql - Fatal编程技术网

Java 在HQL查询中从依赖实体中选择属性

Java 在HQL查询中从依赖实体中选择属性,java,hibernate,hql,Java,Hibernate,Hql,我有以下实体: @Entity class A { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") String id; //some field @ManyToMany Set<B> other; } @Entity class B { @

我有以下实体:

@Entity
class A {
   @Id
   @GeneratedValue(generator = "system-uuid")
   @GenericGenerator(name = "system-uuid", strategy = "uuid2")
   String id;
        //some field        

   @ManyToMany
   Set<B> other;
}

@Entity
class B {
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid2")
    String id;
    //some field
}

试着这样做:

select a.other.id from A a join a.other o where a.id = :pid

你试过了吗?我不确定,但我认为您应该在投影中使用别名(因此
select o.id…
)。不,我没有测试它,这是我认为我记得的,对不起。引发了什么异常,您如何从hibernate调用它。另见
select a.other.id from A a join a.other o where a.id = :pid