Java 使用Hibernate条件连接不同列上的三个实体所需的帮助 更新问题

Java 使用Hibernate条件连接不同列上的三个实体所需的帮助 更新问题,java,hibernate,join,Java,Hibernate,Join,我有三张像这样的桌子 Section (id, title, url)//id is Primary key Category (id, title)//id is Primary key SubCategory (id, title)//id is Primary key 在这里,我想像在简单的查询中一样连接这些表 Select * From Category cat, Section se, SubCategory subCat WHERE subCat.id=23456 AND s

我有三张像这样的桌子

Section (id, title, url)//id is Primary key
Category (id, title)//id is Primary key
SubCategory (id, title)//id is Primary key
在这里,我想像在简单的查询中一样连接这些表

Select * From Category cat, Section se, SubCategory subCat  WHERE
 subCat.id=23456  AND subCat.category=cat.id  AND subCat.section = se.id
如何在Hibernate中使用条件实现上述查询?可以 有人帮我吗

在这里添加我的问题 我的实体文件如下:

@Entity
@Table(name="section")
public class SectionEntity{
  private int id;
  private String title;
  //Getter & setter method
}
但我需要的查询如下:
我怎样才能做到这一点,有人能帮我吗?

在您的子类别文件中,做出这样的更改

1.删除专用int段;以及所有的getter和setter方法

2.用这个

       @JoinColumn(name="section", insertable=false, updatable=false)
       public Set<SectionEntity> getSection(){
          this.section;
           }

然后试着跑。我希望它能在Linkedin上起作用

同样的问题,请检查下面的链接可能重复Hi Frazz,我不明白你的意思,请指定你的答案,如果你知道的话。我正在努力清理这个混乱。请你通读一下帮助中心。这可能会帮助你更好地理解问题和答案是如何在这里工作的。这两个问题实际上是相同的。只有一个必须存在,与所有相关的信息,也许一些更好的格式。弗拉兹,我已经删除了前面的问题。嘿,这对你有帮助吗@User1091269在引用节表的节实体中,没有“节”列/字段。此外,我没有更新子类别Entity,SectionEntity的对象应该是SectionEntity而不是section。这是我的错误,我错过了更新。请给我表的relationforeign键。表中没有外键。现在,请告诉我如何才能做到这一点?
@Entity
@Table(name="subcategory")
public class SubCategoryEntity{
  private int id;
  private String title;

  private Set<SectionEntity> sectionEntity;

  //Getter & setter method
  @OneToMany(fetch=FetchType.LAZY)
  @JoinColumn(name="id", insertable=false, updatable=false)
  public Set<SectionEntity> getSectionEntity(){
    this.section;
  }
}
select this_.id as y0_, this_.title as y1_, this_.sef_url as y2_, subcatenti1_.id as y3_, subcatenti1_.title as y4_, subcatenti1_.sef_url as y5_
from jos_categories this_
inner join jos_subcategories subcatenti1_ on this_.id=subcatenti1_.category
inner join jos_sections subcatsect2_ on subcatenti1_.id=subcatsect2_.id
where subcatenti1_.id=?
select this_.id as y0_, this_.title as y1_, this_.sef_url as y2_, subcatenti1_.id as y3_, subcatenti1_.title as y4_, subcatenti1_.sef_url as y5_
from jos_categories this_
inner join jos_subcategories subcatenti1_ on this_.id=subcatenti1_.category
inner join jos_sections subcatsect2_ on subcatenti1_.section=subcatsect2_.id
where subcatenti1_.id=?
       @JoinColumn(name="section", insertable=false, updatable=false)
       public Set<SectionEntity> getSection(){
          this.section;
           }