java - Hibernate Named Query: syntax error near , -
i'm tryint run postgres function named query in hibernate.
my function signature is:
create or replace function dummy_function(par1 integer[] default '{}'::integer[], par2 integer[] default '{}'::integer[]) returns table(id integer, name character varying, qualified_name)
as can see parameters arrays of integer.
here query mapping:
<sql-query name="myfn" callable="true"> <return-scalar column="id" type="int" /> <return-scalar column="name" type="string" /> <return-scalar column="qualified_name" type="string" /> { ? = call dummy_function(:par1, :par2)} </sql-query>
when try perform query:
query query = session.getnamedquery("myfn"); query.setparameterlist("par1", arraylist1.toarray()); query.setparameterlist("par2", arraylist2.toarray()); query.setresulttransformer(transformers.aliastobean(mycustombean.class)); result = (list<mycustombean>) query.list();
i following error: "syntax error near ," (complete stack trace reported below).
can me?
thanks, laura
=====stack trace ========
warn [main] (sqlexceptionhelper.java:144) - sql error: 0, sqlstate: 42601 error [main] (sqlexceptionhelper.java:146) - error: syntax error @ or near "," posizione: 26 error [main] (namedquerytestcase.java:104) - org.hibernate.exception.sqlgrammarexception: not extract resultset org.hibernate.hibernateexception: org.hibernate.exception.sqlgrammarexception: not extract resultset @ eu.test.datalayer.testdao.stackoverflowquestion(testdao.java:4412) @ eu.test.test.namedquerytestcase.testgethostscomponentslevel(namedquerytestcase.java:98) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:50) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:47) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17) @ org.junit.runners.parentrunner.runleaf(parentrunner.java:325) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:78) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:57) @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:26) @ org.junit.runners.parentrunner.run(parentrunner.java:363) @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:86) @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:459) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:678) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:382) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:192) caused by: org.hibernate.exception.sqlgrammarexception: not extract resultset @ org.hibernate.exception.internal.sqlstateconversiondelegate.convert(sqlstateconversiondelegate.java:123) @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:49) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:126) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:112) @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.extract(resultsetreturnimpl.java:91) @ org.hibernate.loader.loader.getresultset(loader.java:2066) @ org.hibernate.loader.loader.executequerystatement(loader.java:1863) @ org.hibernate.loader.loader.executequerystatement(loader.java:1839) @ org.hibernate.loader.loader.doquery(loader.java:910) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:355) @ org.hibernate.loader.loader.dolist(loader.java:2554) @ org.hibernate.loader.loader.dolist(loader.java:2540) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2370) @ org.hibernate.loader.loader.list(loader.java:2365) @ org.hibernate.loader.custom.customloader.list(customloader.java:353) @ org.hibernate.internal.sessionimpl.listcustomquery(sessionimpl.java:1909) @ org.hibernate.internal.abstractsessionimpl.list(abstractsessionimpl.java:311) @ org.hibernate.internal.sqlqueryimpl.list(sqlqueryimpl.java:141) @ eu.test.datalayer.testdao.stackoverflowquestion(testdao.java:4407) ... 25 more caused by: org.postgresql.util.psqlexception: error: syntax error @ or near "," posizione: 26 @ org.postgresql.core.v3.queryexecutorimpl.receiveerrorresponse(queryexecutorimpl.java:2284) @ org.postgresql.core.v3.queryexecutorimpl.processresults(queryexecutorimpl.java:2003) @ org.postgresql.core.v3.queryexecutorimpl.execute(queryexecutorimpl.java:200) @ org.postgresql.jdbc.pgstatement.execute(pgstatement.java:424) @ org.postgresql.jdbc.pgpreparedstatement.executewithflags(pgpreparedstatement.java:161) @ org.postgresql.jdbc.pgpreparedstatement.executequery(pgpreparedstatement.java:114) @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.extract(resultsetreturnimpl.java:82) ... 39 more
Comments
Post a Comment