zoukankan      html  css  js  c++  java
  • 查询生成三大框架整合 提示 不能进行查询错误

    改章节是一篇关于查询生成的帖子

        这是抛出来的提示信息:

        

    HTTP Status 500 - could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query

        


        type Exception report

        message could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query

        description The server encountered an internal error that prevented it from fulfilling this request.

        exception

    org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
    	org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:613)
    	org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)

        提示是没法进行查询,我们可以把他生成的sql 复制在sql editer中去运行下,你就会发现错误了

        很有可能是因为表名 或者字段名 是sql的关键字引发的。

        在bean的hbm.xml 文件中给字段 或者 表名加上回避符就能够了。[表名]

        附上一段我报错的配置文件,修复准确的:

        每日一道理
    曾经辉煌过,曾经凋零过,这可是你至死不渝的生活吗?我亲爱的母亲—大自然。多少次,我伏在地上,去聆听你沉重的脉搏声;多少次,我伫立在山前,去感受那松涛千年的浩瀚。你的豪壮,足以让中华民族腾飞;你的无私,谱写了一曲曲感人至深的千古壮曲。
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse Persistence Tools
    -->
    <hibernate-mapping>
        <class name="com.shop.bean.Order" table="[Order]" schema="dbo" catalog="Shop" dynamic-insert="true" dynamic-update="true">
            <id name="id" type="java.lang.Integer">
                <column name="Id" />
                <generator class="native" />
            </id>
            <many-to-one name="product" class="com.shop.bean.Product" fetch="select">
                <column name="ProductId" not-null="true" />
            </many-to-one>
            <many-to-one name="user" class="com.shop.bean.User" fetch="select">
                <column name="UserId" not-null="true" />
            </many-to-one>
            <many-to-one name="convey" class="com.shop.bean.Convey" fetch="select">
                <column name="ConveyId" not-null="true" />
            </many-to-one>
            <property name="price" type="java.lang.Double">
                <column name="[Price]" scale="4" not-null="true" />
            </property>
            <property name="count" type="java.lang.Integer">
                <column name="[Count]" not-null="true" />
            </property>
            <property name="money" type="java.lang.Double">
                <column name="[Money]" scale="4" not-null="true" />
            </property>
            <property name="shipments" type="java.lang.Boolean">
                <column name="Shipments" />
            </property>
            <property name="address" type="java.lang.String">
                <column name="[Address]" not-null="true" />
            </property>
            <property name="receive" type="java.lang.Boolean">
                <column name="Receive" />
            </property>
            <property name="addTime" type="java.sql.Timestamp">
                <column name="AddTime" length="23" />
            </property>
        </class>
    </hibernate-mapping>

    文章结束给大家分享下程序员的一些笑话语录: 某程序员对书法十分感兴趣,退休后决定在这方面有所建树。花重金购买了上等的文房四宝。一日突生雅兴,一番磨墨拟纸,并点上了上好的檀香,颇有王羲之风 范,又具颜真卿气势,定神片刻,泼墨挥毫,郑重地写下一行字:hello world.

  • 相关阅读:
    innerHTML与appendChild(newnodeText)的区别
    转]解析C语言中的sizeof
    #pragma 预处理指令详解
    Linux目录结构和常用命令
    Linux下select, poll和epoll IO模型的详解
    重载,继承,重写和多态的区别:
    CentOs7实现lvs+nginx+keepalived负载均衡(DR模式)
    shell中的通配符(grep、cut、sort等)
    kali虚拟机 联网问题解决办法
    MongoDB 数据库
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3084564.html
Copyright © 2011-2022 走看看