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 8593909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:05:36+00:00 2026-06-12T00:05:36+00:00

I am getting the error of not all named parameters have been set .

  • 0

I am getting the error of not all named parameters have been set. Below is my code.

my SqlQuery which is running fine at mysql prompt, You can refer schema in the question SQL Query

SELECT  t.*
FROM    (
    SELECT  @lim := 2,
            @cg := ''
    ) vars,
    (select * from Table1 order by product,amount, make)  t
WHERE   CASE WHEN @cg <> product THEN @r := @lim ELSE 1 END > 0
    AND (@r := @r - 1) >= 0
    AND (@cg := product) IS NOT NULL
ORDER BY
    product,amount, make

my java code

try {
             context.dbl.startTransaction();
             Session session = context.dbl.getSession();

             //String sqlQuery = "from com.infibeam.inventoryservice.dbObjects.PopularBrandDO";
             String sqlQuery = "SELECT  t.* ";
             sqlQuery=sqlQuery + "FROM    (";
             sqlQuery=sqlQuery + "SELECT  @lim := 2,";
             sqlQuery=sqlQuery + "@cg := ''";
             sqlQuery=sqlQuery + ") vars, ";
             sqlQuery=sqlQuery + "(select * from Table1 order by product,amount, make) t";
             sqlQuery=sqlQuery + " WHERE   CASE WHEN @cg <> product THEN @r := @lim ELSE 1 END > 0";
             sqlQuery=sqlQuery + " AND (@r := @r - 1) >= 0 ";
             sqlQuery=sqlQuery + " AND (@cg := product) IS NOT NULL ";
             sqlQuery=sqlQuery + " ORDER BY product,amount, make";
             //Query query = session.createQuery(sqlQuery);
             SQLQuery query = session.createSQLQuery(sqlQuery);
             listItems = query.list();


            }catch(RuntimeException e) {
                e.printStackTrace();
            }

Below is the exception i am getting

org.hibernate.QueryException: Not all named parameters have been set: [] [SELECT  t.* FROM    (SELECT  @lim := 2,@cg := '') vars, (select * from Table1 order by product,amount, make) t WHERE   CASE WHEN @cg <> product THEN @r := @lim ELSE 1 END > 0 AND (@r := @r - 1) >= 0  AND (@cg := product) IS NOT NULL  ORDER BY product,amount, make]
    at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:291)
    at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:199)
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:143)
    at com.infibeam.weaverbird.helper.PopularBrandFacetHelper.bootstrap(PopularBrandFacetHelper.java:48)

Thanks in advance…

  • 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-12T00:05:37+00:00Added an answer on June 12, 2026 at 12:05 am

    The problem is the assignments with :=, which are by the way no standard SQL.

    In SQL after a : always a parameter is expected, like in where value = :param and :param has the be set as a parameter then. Now hibernate is scanning the select and find colons where no set parameters follow.

    Solution: Redesign your selection using hibernate standards.

    You can use two different HQL queries.

    First: Select all product: select distinct product from Table1

    Second: For each product you do from Table1 where product = :prod, :prod you set as a parameter with the actual product, and with setMaxResults(2) you can limit the number of rows as you need.

    Now it is many selects and not a single one, but nevertheless they might be faster than the single query (the single query is complicated and risks an inefficient search strategy in the database). And a big advantage, now it is purely HQL and so your program is portable to different databases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an compilation error not a statement for the below code. Not
I'm getting the error T does not contain a definition for Id below in
Getting an error with my code found HERE ... Which is a culmination of
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I am getting the error: 'string[]' does not contain a definition for 'Cast' and
I keep getting the error: Type was not found or was not a compile-time
I'm getting the error: parser error : Input is not proper UTF-8, indicate encoding
I am getting an error I do not understand. I am using File:Find to
I'm getting an error msg DataReader.h:13: error: 'String' was not declared in this scope
I am not getting any error message in browser due to curly brace missing

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.