Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
1.2.0
-
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>