NetBeans HQL编辑器错误翻译为SQL [英] NetBeans HQL editor wrong translation to SQL

查看:116
本文介绍了NetBeans HQL编辑器错误翻译为SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Java Web服务访问MySQL数据库.我正在使用NetBeans IDE,并正在遵循教程 在Web应用程序

I'm trying to access a MySQL database from a Java webservice. I'm using the NetBeans IDE and am following the tutorial Using Hibernate in a Web Application

现在,当我尝试测试 HQL 查询:从我得到的电话中:

Now when I try to test the HQL query: from calls I get:

org.hibernate.exception.SQLGrammarException: could not execute query
    blablabla
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 'from limit 100' at line 1
    bla, bla, bla

翻译的SQL也是错误的:

And the translated SQL is also wrong:

select  from

我使用Hibernate Reverse Engineering创建了calls.java类.

I created the calls.java class using Hibernate Reverse Engineering.

这是Hibernate.cfg.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/datacheck</property>
        <property name="hibernate.connection.username">admin</property>
        <property name="hibernate.connection.password">####</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
    </session-factory>
</hibernate-configuration>

我似乎找不到错误,我搜索了整个Internet:p

I can't seem to find the error, and I searched the whole Internet :p

类似的线程是 HQL编辑器未在查询中添加表名 .

A similar thread is HQL Editor not appending table name in query.

推荐答案

我输入了HQL查询

from call

应为:

from Call

首字母大写.

愚蠢的错误,我以为是数据库表,但显然是 POJO 这个名字您必须指定.

Dumb mistake, I thought it was the database table, but apparently it's the POJO name that you have to specify.

这篇关于NetBeans HQL编辑器错误翻译为SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆