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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:12:28+00:00 2026-06-17T05:12:28+00:00

One of my DAO methods contains the following method: @Override public boolean isAvailable(String code)

  • 0

One of my DAO methods contains the following method:

@Override
public boolean isAvailable(String code) {
    Criteria criteria = getSession().createCriteria(MyEntity.class);
    cr.add(Restrictions.eq("code", code).ignoreCase());
    cr.setProjection(Projections.rowCount());
    Long rowCount = (Long) cr.uniqueResult();
    return (rowCount > 0) ? true : false;
}

On the last line the following exception is thrown:

org.hibernate.exception.DataException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2452)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
at org.hibernate.loader.Loader.list(Loader.java:2187)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1706)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:369)

The code is primary key in this table. Hibernate is generating its select command in console. When I am checking this select command in SQL console in my database it returns correct values. So what am I doing wrong?

  • 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-17T05:12:29+00:00Added an answer on June 17, 2026 at 5:12 am

    Solution to my problem was very tricky. The parameter code in my method in question above was the key to solution. At the beginning I have column corresponding to this parameter in Hibernate entity class, defined as a varchar with 5 signs length. In the meantime I had to change its length to only 2 signs. But I was invoking the method still with 5 signs String length. And this is why my error has occurred. I have changed again length of the varchar to the 5 signs and everything is alright in this moment.

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

Sidebar

Related Questions

My class contains 14 private methods and 1 public method . The public method
Currently I have one dao, that uses generic methods and hibernate criteria to perform
in one dao I have 2 @Transactional methods. if i do not provide any
I have the following code in a Spring JdbcTemplate based dao - getJdbcTemplate().update(Record Insert
Most of the DAO examples I've seen consist of simple queries only involving one
One of my processes is restarting over and over apparently because of following messages
I have a wicket page , which contains two Spring-managed beans , one is
I'm looking at a couple of designs for DAO interfaces. One has a single
In one of our service classes I have a bunch of methods which just
I develop application using Spring, Hibernate and MySQL. I created DAO for one of

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.