Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-193

No escape of reserved words in hibernate calls

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 1.2.0
    • 1.2.3
    • Other
    • Win7 but I thing the problem is on all platforms, mariadb 10, hibernate 3

    Description

      I've to use tables with reserved words in mariadb.
      Here is an example:
      CREATE BASE TABLE t1(
      `table` VARCHAR(20),
      )ENGINE=InnoDB;

      If I try to insert data into this table using the Hibernate persist function:
      @Transactional(readOnly = false)
      public T add(final T t) {
      this.getEntityManager().persist(t);
      this.getEntityManager().flush();
      return t;
      }

      MariaDB throws a "systax error".

      Reason is, that the reserved word is not escaped in the resulting hibernate request !

      This is the generated request:
      sql : 'insert into t1 ( table) values ', parameters: ['myt']

      A correct request should look like this (with escaped attribute table):
      sql : 'insert into t1 ( `table` ) values ', parameters: ['myt']

      I'm not 100% sure, but I think the implementation org.hibernate.dialect is responsible for database specific implementations and should escape the reserved words.

      I specified the dialect this way by using MYSQL, because there is no seperate MARIADB dialect.

      <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
      <property name="generateDdl" value="false" />
      <property name="showSql" value="true" />
      <property name="database" value="MYSQL" />
      </bean>
      </property>

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            skuepper Stefan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.