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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:01:28+00:00 2026-05-26T11:01:28+00:00

I am using Hibernate to access MySQL database for my java application. I configured

  • 0

I am using Hibernate to access MySQL database for my java application. I configured Hibernate using this instructions .Now I want to have query to my database; using this code:

java.util.List categList = null;
SessionFactory sessionFacoryt ;
sessionFacoryt = NewHibernateUtil.getSessionFactory();
org.hibernate.classic.Session hiberanateSession = sessionFacoryt.getCurrentSession();
String HQL = "select r from RssCategory r";
Transaction transaction = hiberanateSession.beginTransaction();                
org.hibernate.Query q = hiberanateSession.createQuery(HQL);

// here is the Exception cause line  
categList = q.list();

as you see because of the last line; I see this Exception:

Oct 23, 2011 3:20:25 PM org.hibernate.util.JDBCExceptionReporter
logExceptions WARNING: SQL Error: 1064, SQLState: 42000 Oct 23, 2011
3:20:25 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '-IPTV-EPG.rss_category rsscategor0_' at line 1
org.hibernate.exception.SQLGrammarException: could not execute query at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)     at
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)  at
org.hibernate.loader.Loader.list(Loader.java:2099)  at
org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912) at
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) at
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)  at
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)    at
RSS.connectHtmlandleRSS.addTODB(connectHtmlandleRSS.java:206)   at
RSS.connectHtmlandleRSS.access$000(connectHtmlandleRSS.java:37)     at
RSS.connectHtmlandleRSS$1.run(connectHtmlandleRSS.java:163) Caused by:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near
'-IPTV-EPG.rss_category rsscategor0_' at line 1     at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at
java.lang.reflect.Constructor.newInstance(Constructor.java:513) at
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)    at
com.mysql.jdbc.Util.getInstance(Util.java:384)  at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)  at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)  at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)  at
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)   at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)    at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)     at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113) at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2275) at
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) at 
org.hibernate.loader.Loader.getResultSet(Loader.java:1787)  at
org.hibernate.loader.Loader.doQuery(Loader.java:674)    at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at
org.hibernate.loader.Loader.doList(Loader.java:2220)

can anyone guide me for the cause of this exception ?
thanks.

here is mapping generated for RssCategory; This class was generated to this package sakila.entity.

<hibernate-mapping>
    <class name="sakila.entity.RssCategory" table="rss_category" catalog="SAMIM-IPTV-EPG">
        <id name="catId" type="int">
            <column name="cat_id" />
            <generator class="assigned" />
        </id>
        <property name="catName" type="string">
            <column name="cat_name" length="45" not-null="true" unique="true" />
        </property>
        <set name="rssNewses" inverse="true" table="rss_to_cat">
            <key>
                <column name="cat_id" not-null="true" />
            </key>
            <many-to-many entity-name="sakila.entity.RssNews">
                <column name="rss_id" not-null="true" />
            </many-to-many>
        </set>
    </class> </hibernate-mapping>

and here is the SQL code generated for rss_category:

CREATE TABLE `rss_category` (
  `cat_id` int(11) NOT NULL,
  `cat_name` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`cat_id`),
  UNIQUE KEY `cat_name_UNIQUE` (`cat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

and the HQL query generated by Hibernate is:

Hibernate: select rsscategor0_.cat_id as cat1_4_, rsscategor0_.cat_name as cat2_4_ from SAMIM-IPTV-EPG.rss_category rsscategor0_
  • 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-05-26T11:01:28+00:00Added an answer on May 26, 2026 at 11:01 am

    The problem is certainly caused by the dashes in the catalog name. Try to change the name of the catalog to something else, without dashes.

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

Sidebar

Related Questions

I am using Hibernate in a Java application to access my Database and it
I'm building a Route Planner Webapp using Spring/Hibernate/Tomcat and a mysql database, I have
I have a struts application that uses Hibernate to access a MYSQL DB. I
There's an enterprise application using Java + Hibernate + PostgreSQL. Hibernate is configured via
I am using Hibernate in an Eclipse RAP application. I have database tables mapped
I needed to create an application using Struts2 as MVC,Hibernate for data access and
I'm using Hibernate for ORM of my Java app to an Oracle database (not
my problem is that, i want to save class object java.lang.reflect.Field into database using
Using Hibernate in a struts2 webapp when the application redeploys I get this error
Background: I am using hibernate objects for database access. inside my servlet's doGet I

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.