Path expected for join

Entity relationship between Asset, pstupdatefile and checkedouthistory When trying to join these am getting the error message path expected for join

here am adding my entities and db query

@Entity
@Table(name = "POST_UPDATE_FILE")
public class PostUpdateFile implements java.io.Serializable {

    private int postUpdateFileId;
    private Reason reasonByReasonForReprocessing;
    private Reason reasonByReasonForFailure;
    private Package softwarePackage;
    private Asset asset;
    private String upgradeStatus;
    private boolean manuallyProcessed;
    private String eventLogfileId;
    private String comment;
    private boolean operationManualHandover;
    private Date updatedOn;
    private String updatedBy;
    private Date processedOn;
    private String processedBy;
    private String fileSource;
    private String previousVersion;
    private String currentVersion;
    private Set<PostUpdateRetryCount> postUpdateRetryCounts = new HashSet<>(0);

    @Id

    @Column(name = "POST_UPDATE_FILE_ID", unique = true, nullable = false)
    public int getPostUpdateFileId() {
        return this.postUpdateFileId;
    }

    public void setPostUpdateFileId(int postUpdateFileId) {
        this.postUpdateFileId = postUpdateFileId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "REASON_FOR_REPROCESSING")
    public Reason getReasonByReasonForReprocessing() {
        return this.reasonByReasonForReprocessing;
    }

    public void setReasonByReasonForReprocessing(Reason reasonByReasonForReprocessing) {
        this.reasonByReasonForReprocessing = reasonByReasonForReprocessing;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "REASON_FOR_FAILURE")
    public Reason getReasonByReasonForFailure() {
        return this.reasonByReasonForFailure;
    }

    public void setReasonByReasonForFailure(Reason reasonByReasonForFailure) {
        this.reasonByReasonForFailure = reasonByReasonForFailure;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="PACKAGE_ID", nullable=false)
    public Package getSoftwarePackage() {
        return softwarePackage;
    }

    public void setSoftwarePackage(Package softwarePackage) {
        this.softwarePackage = softwarePackage;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ASSET_SERIAL_NUMBER", nullable = false)
    public Asset getAsset() {
        return this.asset;
    }

    public void setAsset(Asset asset) {
        this.asset = asset;
    }

    @Column(name = "UPGRADE_STATUS", length = 12)
    public String getUpgradeStatus() {
        return this.upgradeStatus;
    }

    public void setUpgradeStatus(String upgradeStatus) {
        this.upgradeStatus = upgradeStatus;
    }

    @Column(name = "MANUALLY_PROCESSED", nullable = false)
    public boolean isManuallyProcessed() {
        return this.manuallyProcessed;
    }

    public void setManuallyProcessed(boolean manuallyProcessed) {
        this.manuallyProcessed = manuallyProcessed;
    }



    @Column(name = "COMMENT", length = 512)
    public String getComment() {
        return this.comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Column(name = "OPERATION_MANUAL_HANDOVER", nullable = false)
    public boolean isOperationManualHandover() {
        return this.operationManualHandover;
    }

    public void setOperationManualHandover(boolean operationManualHandover) {
        this.operationManualHandover = operationManualHandover;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATED_ON", nullable = false, length = 19)
    public Date getUpdatedOn() {
        return this.updatedOn;
    }

    public void setUpdatedOn(Date updatedOn) {
        this.updatedOn = updatedOn;
    }

    @Column(name = "UPDATED_BY", nullable = false, length = 12)
    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "PROCESSED_ON", nullable = false, length = 19)
    public Date getProcessedOn() {
        return this.processedOn;
    }

    public void setProcessedOn(Date processedOn) {
        this.processedOn = processedOn;
    }

    @Column(name = "PROCESSED_BY", nullable = false, length = 12)
    public String getProcessedBy() {
        return this.processedBy;
    }

    public void setProcessedBy(String processedBy) {
        this.processedBy = processedBy;
    }

    @Column(name = "EVENT_LOGFILE_ID", length = 30)
    public String getEventLogfileId() {
        return this.eventLogfileId;
    }

    public void setEventLogfileId(String eventLogfileId) {
        this.eventLogfileId = eventLogfileId;
    }

    @Column(name = "FILE_SOURCE", length = 10)
    public String getFileSource() {
        return this.fileSource;
    }

    public void setFileSource(String fileSource) {
        this.fileSource = fileSource;
    }

    @Column(name = "PREVIOUS_VERSION", length = 16)
    public String getPreviousVersion() {
        return this.previousVersion;
    }

    public void setPreviousVersion(String previousVersion) {
        this.previousVersion = previousVersion;
    }

    @Column(name = "CURRENT_VERSION", length = 16)
    public String getCurrentVersion() {
        return this.currentVersion;
    }

    public void setCurrentVersion(String currentVersion) {
        this.currentVersion = currentVersion;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "postUpdateFile")
    public Set<PostUpdateRetryCount> getPostUpdateRetryCounts() {
        return this.postUpdateRetryCounts;
    }

    public void setPostUpdateRetryCounts(Set<PostUpdateRetryCount> postUpdateRetryCounts) {
        this.postUpdateRetryCounts = postUpdateRetryCounts;
    }

}



@Entity
@Table(name = "CHECK_OUT_HISTORY")
public class CheckOutHistory implements java.io.Serializable {

    private int checkOutHistoryId;
    private Package softwarePackage;
    private User user;
    private Asset asset;
    private Date checkedOutOn;

    @Id

    @Column(name = "CHECK_OUT_HISTORY_ID", unique = true, nullable = false)
    public int getCheckOutHistoryId() {
        return this.checkOutHistoryId;
    }

    public void setCheckOutHistoryId(int checkOutHistoryId) {
        this.checkOutHistoryId = checkOutHistoryId;
    }


    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="PACKAGE_ID", nullable=false)
    public Package getSoftwarePackage() {
        return softwarePackage;
    }

    public void setSoftwarePackage(Package softwarePackage) {
        this.softwarePackage = softwarePackage;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CHECKED_OUT_BY", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ASSET_SERIAL_NUMBER", nullable = false)
    public Asset getAsset() {
        return this.asset;
    }

    public void setAsset(Asset asset) {
        this.asset = asset;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CHECKED_OUT_ON", nullable = false, length = 19)
    public Date getCheckedOutOn() {
        return this.checkedOutOn;
    }

    public void setCheckedOutOn(Date checkedOutOn) {
        this.checkedOutOn = checkedOutOn;
    }

}



@Entity
@Table(name = "ASSET", uniqueConstraints = @UniqueConstraint(columnNames = "SYSTEM_ID"))
public class Asset implements java.io.Serializable {

    private String assetSerialNumber;
    private Account account;
    private Country country;
    private User energySalesPerson;
    private Product product;
    private Status status;
    private String softwareVersion;
    private boolean checkedOut;
    private int systemId;
    private Date lastUpdatedOn;
    private String lastUpdatedBy;
    private String modifiedAttributes;
    private String checkedOutBy;
    private Integer shipLocationId;
    private String sourceCountry;
    private AccountLocation accountLocation;
    private Set<CheckInHistory> checkInHistories = new HashSet<>(0);
    private Set<CheckOutHistory> checkOutHistories = new HashSet<>(0);
    private Set<PostUpdateFile> postUpdateFiles = new HashSet<>(0);
    private Set<ReassignedAsset> reassignedAssets = new HashSet<>(0);
    @Id

    @Column(name = "ASSET_SERIAL_NUMBER", unique = true, nullable = false, length = 16)
    public String getAssetSerialNumber() {
        return this.assetSerialNumber;
    }

    public void setAssetSerialNumber(String assetSerialNumber) {
        this.assetSerialNumber = assetSerialNumber;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ACCOUNT_ID")
    public Account getAccount() {
        return this.account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ENERGY_SALES_PERSON")
    public User getEnergySalesPerson() {
        return energySalesPerson;
    }

    public void setEnergySalesPerson(User energySalesPerson) {
        this.energySalesPerson = energySalesPerson;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SIEBEL_PRODUCT_CODE")
    public Product getProduct() {
        return this.product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "LAST_UPDATED_STATUS")
    public Status getStatus() {
        return this.status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    @Column(name = "SOFTWARE_VERSION", nullable = false, length = 16)
    public String getSoftwareVersion() {
        return this.softwareVersion;
    }

    public void setSoftwareVersion(String softwareVersion) {
        this.softwareVersion = softwareVersion;
    }

    @Column(name = "CHECKED_OUT", nullable = false)
    public boolean isCheckedOut() {
        return this.checkedOut;
    }

    public void setCheckedOut(boolean checkedOut) {
        this.checkedOut = checkedOut;
    }

    @Column(name = "SYSTEM_ID", unique = true, nullable = false)
    public int getSystemId() {
        return this.systemId;
    }

    public void setSystemId(int systemId) {
        this.systemId = systemId;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "LAST_UPDATED_ON", nullable = false, length = 19)
    public Date getLastUpdatedOn() {
        return this.lastUpdatedOn;
    }

    public void setLastUpdatedOn(Date lastUpdatedOn) {
        this.lastUpdatedOn = lastUpdatedOn;
    }

    @Column(name = "LAST_UPDATED_BY", nullable = false, length = 12)
    public String getLastUpdatedBy() {
        return this.lastUpdatedBy;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    @Column(name = "MODIFIED_ATTRIBUTES", length = 100)
    public String getModifiedAttributes() {
        return this.modifiedAttributes;
    }

    public void setModifiedAttributes(String modifiedAttributes) {
        this.modifiedAttributes = modifiedAttributes;
    }

    @Column(name = "CHECKED_OUT_BY", length = 12)
    public String getCheckedOutBy() {
        return this.checkedOutBy;
    }

    public void setCheckedOutBy(String checkedOutBy) {
        this.checkedOutBy = checkedOutBy;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "asset")
    public Set<CheckInHistory> getCheckInHistories() {
        return this.checkInHistories;
    }

    public void setCheckInHistories(Set<CheckInHistory> checkInHistories) {
        this.checkInHistories = checkInHistories;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "asset")
    public Set<CheckOutHistory> getCheckOutHistories() {
        return this.checkOutHistories;
    }

    public void setCheckOutHistories(Set<CheckOutHistory> checkOutHistories) {
        this.checkOutHistories = checkOutHistories;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "asset")
    public Set<PostUpdateFile> getPostUpdateFiles() {
        return this.postUpdateFiles;
    }

    public void setPostUpdateFiles(Set<PostUpdateFile> postUpdateFiles) {
        this.postUpdateFiles = postUpdateFiles;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "asset")
    public Set<ReassignedAsset> getReassignedAssets() {
        return this.reassignedAssets;
    }

    public void setReassignedAssets(Set<ReassignedAsset> reassignedAssets) {
        this.reassignedAssets = reassignedAssets;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "COUNTRY_CODE")
    public Country getCountry() {
        return this.country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    @Column(name = "SHIP_LOCATION_ID")
    public Integer getShipLocationId() {
        return this.shipLocationId;
    }

    public void setShipLocationId(Integer shipLocationId) {
        this.shipLocationId = shipLocationId;
    }

    @Column(name = "SOURCE_COUNTRY", length = 32)
    public String getSourceCountry() {
        return this.sourceCountry;
    }

    public void setSourceCountry(String sourceCountry) {
        this.sourceCountry = sourceCountry;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ASSET_LOCATION_ID")
    public AccountLocation getAccountLocation() {
        return this.accountLocation;
    }

    public void setAccountLocation(AccountLocation accountLocation) {
        this.accountLocation = accountLocation;
    }

}

query for retrieving the data.its always returning org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join!

  select puf.processedOn,coh.checkedOutOn from Asset a inner join PostUpdateFile puf on a.assetSerialNumber=puf.assetSerialNumber inner join CheckOutHistory coh on a.assetSerialNumber=coh.assetSerialNumber where a.assetSerialNumber=:assetno

Answer

org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join!

The above exception is talking about join should use a path from one entity to other defined in the mapping.

Your entities show that CheckOutHistory and ProcessUpdateFile are collection members of ASSET.

Instead of

from Asset a
inner join processupdatefile puf 

We need a path from ASSET to ProcessUpdateFile, i.e.

from Asset a
inner join a.postUpdateFiles puf 

The HQL should look like:

select 
    puf.processedOn,
    coh.checkedOutOn 
from Asset a 
inner join a.postUpdateFiles puf 
    on a.assetSerialNumber = puf.assetSerialNumber 
inner join a.checkOutHistories coh 
    on a.assetSerialNumber = coh.assetSerialNumber 
where a.assetSerialNumber =: assetno

Leave a Reply

Your email address will not be published. Required fields are marked *