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

  • Home
  • SEARCH
  • 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 8511731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:05:15+00:00 2026-06-11T04:05:15+00:00

how to write this query in hibernate query language select * from preferred_space p,

  • 0

how to write this query in hibernate query language

select * from preferred_space p, building b, floor f, space_type st, space s
    where p.user_id=11
    and p.space_id=s.id
    and s.building_id=b.id
    and s.floor_id=f.id
    and s.space_type_id=st.id 
    order by p.id;

If I do it this way it is showing me an error?

 String sql =    "from     PreferredSpace p, Space s, Building b, Floor f, SpaceType st " +
                 "where    p.userId = ? " +
                 "and      p.spaceId = s.id" +
                 "and      s.buildingId = b.id" +
                 "and      s.floorId = f.id" +
                 "and      s.spaceTypeId = st.id" +
                 "order by p.id";

error:

ERROR o.h.hql.internal.ast.ErrorCounter - line 1:242: unexpected token: s
16:18:17.569 [http-bio-8080-exec-24] ERROR o.h.hql.internal.ast.ErrorCounter - line 1:242: unexpected token: s
antlr.NoViableAltException: unexpected token: s

shows the same error for every row that starts with “s.” and also for “by”.

  • 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-11T04:05:17+00:00Added an answer on June 11, 2026 at 4:05 am

    You need to add spaces:

    String sql = "from     PreferredSpace p, Space s, Building b, Floor f, SpaceType st " +
                 "where    p.userId = ? " +
                 "and      p.spaceId = s.id " +
                 "and      s.buildingId = b.id " +
                 "and      s.floorId = f.id " +
                 "and      s.spaceTypeId = st.id " +
                 "order by p.id";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write this query using Hibernate 3 and Oracle 10. from Alert
Is it possible to write this query in codeigniter active records? $Main_Nav_Query = mysql_query(SELECT
I am using Hibernate and I have this query: List<Person> list = sess.createQuery(from Person).list();
I am trying to write a sub query in this format listObj = session.createQuery(from
Is it possible to re-write this query to restart numbering when the UName changes
I'm having trouble wrapping my head around how to write this query. A hypothetical
Normally when I want to query large result set using Mysql I write this
How can I write a query similar to this one in LINQ to SQL
I'm trying to write a SQL or ActiveRecord query to answer this question: Of
I am trying to write a query that joins another table, but in this

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.