-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: HSQLDB java.sql.SQLException: This function is not supported
PostPosted: Mon Aug 01, 2016 8:42 am 
Newbie

Joined: Mon Aug 01, 2016 8:33 am
Posts: 3
Hi,

Our Dao layer works fine with a mysql backend. How ever when I try to unit test the same using the in memory HsqlDB we are getting the following issue.

Code:
insert into api (api_id, description, name, version) values (null, ?, ?, ?)


the id is actually getting passed as null. Following is my Entity definition

Code:
public class Api {
    @Id
    @Column(name = "api_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

...
...
...

}


I am creating the database whenever the unit test is triggered using the following configuration

Code:
Properties properties = new Properties();
        properties.setProperty(ApiConstants.HIBERNATE_DIALECT, "org.hibernate.dialect.HSQLDialect");
        properties.setProperty(ApiConstants.HIBERNATE_DRIVER_CLASS, "org.hsqldb.jdbcDriver");
        properties.setProperty(ApiConstants.HIBERNATE_CONN_URL, "jdbc:hsqldb:mem:mydb");
        properties.setProperty(ApiConstants.HIBERNATE_CONN_USER, "sa");
        properties.setProperty(ApiConstants.HIBERNATE_CONN_PWD, "");
        properties.setProperty("hibernate.archive.autodetection", "class,hbm");
        properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
        properties.setProperty("hibernate.show_sql", "true");
        return properties;


When i tried to read through, how the table got created , I found the following logs

Code:
create table api (api_id integer generated by default as identity (start with 1), description varchar(255), name varchar(255), version varchar(255), primary key (api_id))



Kindly let me know what I am missing.

Pradeep.


Top
 Profile  
 
 Post subject: Re: Unit testing with HSQL Db fails - @GeneratedValue(strategy =
PostPosted: Mon Aug 01, 2016 10:51 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Could you paste the exact SQL statements that are executed when you try to persist an entity on HSQLDB?


Top
 Profile  
 
 Post subject: Re: Unit testing with HSQL Db fails - @GeneratedValue(strategy =
PostPosted: Mon Aug 01, 2016 9:40 pm 
Newbie

Joined: Mon Aug 01, 2016 8:33 am
Posts: 3
Here is the complete trace of the log. I am using Hibernate 4.3.6.Final and HSQLDB 2.2.8.

Code:
18:05:52.052 [main] DEBUG o.h.e.j.i.LogicalConnectionImpl - Obtained JDBC connection
18:05:52.052 [main] DEBUG o.h.e.t.i.jdbc.JdbcTransaction - initial autocommit status: false
18:05:52.067 [main] DEBUG org.hibernate.engine.spi.ActionQueue - Executing identity-insert immediately
18:05:52.071 [main] DEBUG org.hibernate.SQL - insert into api (api_id, description, name, version) values (null, ?, ?, ?)
18:05:52.076 [main] DEBUG o.h.e.jdbc.spi.SqlExceptionHelper - could not prepare statement [insert into api (api_id, description, name, version) values (null, ?, ?, ?)]
java.sql.SQLException: This function is not supported
   at org.hsqldb.jdbc.Util.sqlException(Unknown Source) ~[hsqldb-1.8.0.10.jar:private-2008/06/01-10:22:29]
   at org.hsqldb.jdbc.Util.notSupported(Unknown Source) ~[hsqldb-1.8.0.10.jar:private-2008/06/01-10:22:29]
   at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source) ~[hsqldb-1.8.0.10.jar:private-2008/06/01-10:22:29]
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$2.doPrepare(StatementPreparerImpl.java:124) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:122) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:55) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3558) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:98) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:490) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:195) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:179) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:214) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:324) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:288) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at org.hibernate.internal.SessionImpl.save(SessionImpl.java:702) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
   at com.trimble.paas.apicloud.dao.impl.api.ApiDao.add(ApiDao.java:34) [classes/:na]
   at com.trimble.paas.apicloud.dao.impl.distributedapidetails.DistributedApiDetailsDaoServiceTest.setUpDb(DistributedApiDetailsDaoServiceTest.java:34) [test-classes/:na]
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80]
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80]
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80]
   at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80]
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) [junit-4.11.jar:na]
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:na]
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) [junit-4.11.jar:na]
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) [junit-4.11.jar:na]
   at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:na]
   at org.junit.runner.JUnitCore.run(JUnitCore.java:160) [junit-4.11.jar:na]
   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) [junit-rt.jar:na]
   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) [junit-rt.jar:na]
   at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) [junit-rt.jar:na]
   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) [junit-rt.jar:na]
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80]
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80]
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80]
   at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80]
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
18:05:52.076 [main] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: -20, SQLState: IM001
18:05:52.076 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - This function is not supported
org.hibernate.exception.GenericJDBCException: could not prepare statement

   at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:196)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:122)
   at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:55)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3558)
   at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:98)
   at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:490)
   at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:195)
   at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:179)
   at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:214)
   at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:324)
   at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:288)
   at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
   at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
   at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
   at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
   at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
   at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
   at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
   at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
   at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707)
   at org.hibernate.internal.SessionImpl.save(SessionImpl.java:702)
   at com.trimble.paas.apicloud.dao.impl.api.ApiDao.add(ApiDao.java:34)
   at com.trimble.paas.apicloud.dao.impl.distributedapidetails.DistributedApiDetailsDaoServiceTest.setUpDb(DistributedApiDetailsDaoServiceTest.java:34)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
   at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
   at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.sql.SQLException: This function is not supported
   at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
   at org.hsqldb.jdbc.Util.notSupported(Unknown Source)
   at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$2.doPrepare(StatementPreparerImpl.java:124)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186)
   ... 42 more



Pradeep


Top
 Profile  
 
 Post subject: Re: Unit testing with HSQL Db fails - @GeneratedValue(strategy =
PostPosted: Tue Aug 02, 2016 12:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
As reported here, you should upgrade HSQLDB from 2.2.8 to 2.2.9.


Top
 Profile  
 
 Post subject: Re: HSQLDB java.sql.SQLException: This function is not supported
PostPosted: Tue Aug 02, 2016 1:03 am 
Newbie

Joined: Mon Aug 01, 2016 8:33 am
Posts: 3
Thank you so much. Upgrading to 2.2.9 solved the issue.

Pradeep.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.