簡體   English   中英

Hibernate從hql查詢創建多個查詢

[英]Hibernate creates more than one query from hql query

我有一種奇怪的效果,即在執行特定的hql查詢時,休眠會觸發多個查詢。 目前,我使用hsqldb 1.8進行開發。

@NamedQuery(name=PointOfInterestLabel.FIND_BY_FIGURE, query="Select pl FROM PointOfInterestLabel pl INNER JOIN pl.poi p WHERE p.figure = :figure")

控制台輸出:

Hibernate: select pointofint0_.id as id5_, pointofint0_.labelId as labelId5_, pointofint0_.locale as locale5_, pointofint0_.pointOfInterestId as pointOfI4_5_ from PointOfInterestLabel pointofint0_ inner join PointOfInterest pointofint1_ on pointofint0_.pointOfInterestId=pointofint1_.id where pointofint1_.figureId=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?
Hibernate: select pointofint0_.id as id1_1_, pointofint0_.figureId as figureId1_1_, pointofint0_.percentageX as percenta2_1_1_, pointofint0_.percentageY as percenta3_1_1_, pointofint0_.x as x1_1_, pointofint0_.y as y1_1_, figure1_.id as id2_0_, figure1_.fileName as fileName2_0_, figure1_.height as height2_0_, figure1_.legende as legende2_0_, figure1_.originalFileHash as original5_2_0_, figure1_.svgHash as svgHash2_0_, figure1_.width as width2_0_ from PointOfInterest pointofint0_ inner join Figure figure1_ on pointofint0_.figureId=figure1_.id where pointofint0_.id=?

我想選擇所有PointOfInterestLabel到給定的數字。 因此,兩個表之間的聯接就足夠了。

數字:

    public class Figure {
    @OneToMany(mappedBy = "figure")
    private List<PointOfInterest> pois = new ArrayList<PointOfInterest>();

興趣點:

public class PointOfInterest extends GenericEntity {
    @ManyToOne
    @JoinColumn(name="figureId", nullable=false)
    private Figure figure;

    @OneToMany(mappedBy="poi")
    private List<PointOfInterestLabel> labels = new ArrayList<PointOfInterestLabel>();

PointOfInterestLabel:

public class PointOfInterestLabel extends GenericEntity {
    private static final long serialVersionUID = 969499193403830375L;

    @Id
    @GeneratedValue
    private long id;

    @ManyToOne
    @JoinColumn(name="pointOfInterestId")
    private PointOfInterest poi;

那我在做什么錯? 我只希望通過聯接將所有PointOfInterestLabel都獲得給定的數字。

問候m

我有一個類似的問題。 不確定是否適合您,但無論如何:

Select distinct pl FROM PointOfInterestLabel pl INNER JOIN FETCH pl.poi p WHERE p.figure = :figure

我認為造成這種情況的原因是渴望加入協會。 默認情況下,會急切地獲取所有ToOne關聯。 您可以通過指定fetchType覆蓋它。 如下更改PointOfInterestLabel類-注意fetch屬性。

public class PointOfInterestLabel extends GenericEntity {
    private static final long serialVersionUID = 969499193403830375L;

    @Id
    @GeneratedValue
    private long id;

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="pointOfInterestId")
    private PointOfInterest poi;

您有兩個OneToManyAssociations:一個是從Figure到POI,另一個是在POI和POIL之間。 這些都是延遲加載的,因為如果您不指定其他任何內容,則這是這些的默認配置。

您還在查詢要從所有3個對應表中選擇數據的查詢:

Select pl FROM PointOfInterestLabel pl INNER JOIN pl.poi p WHERE p.figure = ?

“ FROM PointOfInteresetLabel”在POIL表中查找“ pl.poi”在POI表中查找“ p.figure”在圖形表中查找

如果您未指定即時獲取(在關聯配置中或在HQL查詢中),則會使用N + 1個Select操作加載它們,因此會生成許多SQL查詢

嘗試:

SELECT pointOfInterest FROM Figure AS figure INNER JOIN FETCH figure.pois AS pointOfInterest INNER JOIN FETCH pointOfInterest.labels AS labels WHERE figure=:figure

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM