Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:22:59+00:00 2026-06-05T04:22:59+00:00

I am trying to issue a select from database using HQL here is the

  • 0

I am trying to issue a select from database using HQL

here is the code:

public Collection<Link> getAllLinksForDevice(Device device) {
    Session session = sessionFactory.getCurrentSession();
    String hql = "SELECT Link as l WHERE l.device1 = :deviceId OR l.device2 = :deviceId";
    Query query = session.createQuery(hql); <-- Fails here!!
    query.setParameter("deviceId",device.getId());
    Collection<Link> linkList  = query.list();
    return linkList;
}

and the link entity:

@Id
@Column(name = "id")
@GeneratedValue
private int id;

@ManyToOne
@JoinColumn(name="device1_id")
private Device device1;

@ManyToOne
@JoinColumn(name="device2_id")
private Device device2;

The device Entity:

@Entity
@Table(name = "device")
public class Device {

    @Id
    @Column(name = "id")
    @GeneratedValue
    private int id;

    @Column(name = "dns_Name")
    private String dnsName;

    @Column(name = "ip_address_v4")
    private String ipV4;

    @Column(name = "device_type")
    private int deviceType;

    @ManyToOne
    @JoinColumn(name="area_id")
    private Area area;

But I get an exception:

15:10:55,570 DEBUG ErrorCounter:51 – :0:0: unexpected end of subtree
:0:0: unexpected end of subtree
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3117)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)

and:

15:10:55,622 ERROR PARSER:56 – Invalid path: ‘l.device1’
15:10:55,628 DEBUG ErrorCounter:51 – Invalid path: ‘l.device1’
Invalid path: ‘l.device1’
at org.hibernate.hql.ast.util.LiteralProcessor.lookupConstant(LiteralProcessor.java:135)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:216)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:117)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:113)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:854)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1293)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4243)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3722)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:23:01+00:00Added an answer on June 5, 2026 at 4:23 am

    You have two syntax errors in your HQL query:

    1. There is no from clause. select Link as l where... is invalid. The proper syntax is select l from Link as l where ... or simply select l from Link l where....
    2. The device1 (and device2 field) field of the Link entity is of type Device. You can’t compare it with an ID. Either you compare it with a Device instance, or you compare the ID of device1 with an ID: where l.device1 = :someDeviceInstanceContainingTheIdYouSearchFor or where l.device1.id = :someDeviceId.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue with psql. I am trying to select the records from
I am trying to get serialized results from a WCF service from database using
I’m trying to issue web requests asynchronously. I have my code working fine except
I am having a big issue trying to delete from an UITableView. Just for
I am trying to merge records from an Oracle database table to my local
Ok, so the issue is coming from trying to pull data from a sqlite
My first issue: I am trying to establish connection to MySql database, but I
I am trying to insert an entry into a database using a form created
I'm trying to find a workaround (hack) to some limitations preventing me from using
I'm trying to rewrite some code using the sqldf library in R, which should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.