spring - Hibernate - No value specified for parameter -
i have entity class mapped this:
@entity @table(name = "configuration") @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class jsonconfiguration implements jsonserializable, serializable { private static final long serialversionuid = 1l; @id @notnull @jsonproperty("_id") private integer id; @jsonproperty("config") @notnull @type(type = "jsontype") private string config; public jsonconfiguration(integer id, string config) { this.id = id; this.config = config; } public jsonconfiguration(){ super(); } public integer getid() { return id; } public void setid(integer id) { this.id = id; } public string getconfig() { return config; } public void setconfig(string config) { this.config = config; } }
each time i'm trying update or insert same error:
caused by: org.springframework.dao.dataintegrityviolationexception: not execute statement; sql [n/a]; nested exception org.hibernate.exception.dataexception: not execute statement @ org.springframework.orm.hibernate4.sessionfactoryutils.converthibernateaccessexception(sessionfactoryutils.java:167) @ org.springframework.orm.hibernate4.hibernatetransactionmanager.converthibernateaccessexception(hibernatetransactionmanager.java:730) @ org.springframework.orm.hibernate4.hibernatetransactionmanager.docommit(hibernatetransactionmanager.java:592) @ org.springframework.transaction.support.abstractplatformtransactionmanager.processcommit(abstractplatformtransactionmanager.java:757) @ org.springframework.transaction.support.abstractplatformtransactionmanager.commit(abstractplatformtransactionmanager.java:726) @ org.springframework.transaction.interceptor.transactionaspectsupport.committransactionafterreturning(transactionaspectsupport.java:497) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:277) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:96) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.cglibaopproxy$dynamicadvisedinterceptor.intercept(cglibaopproxy.java:653) @ com.company.ngnms.server.services.cfg.packitloaderimpl$$enhancerbyspringcglib$$3bbeeb14.createcomponentfrompackit(<generated>) @ com.company.ngnms.server.management.data.datapopulatorimpl.createcomponentsandeventdefinition(datapopulatorimpl.java:126) @ com.company.ngnms.server.management.data.datapopulatorimpl.createinitialcomponents(datapopulatorimpl.java:296) @ com.company.ngnms.server.management.data.datapopulatorimpl.dopopulate(datapopulatorimpl.java:274) @ com.company.ngnms.server.management.data.datapopulatorimpl.populatedata(datapopulatorimpl.java:229) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokecustominitmethod(abstractautowirecapablebeanfactory.java:1694) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1633) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1562) ... 59 more caused by: org.hibernate.exception.dataexception: not execute statement @ org.hibernate.exception.internal.sqlstateconversiondelegate.convert(sqlstateconversiondelegate.java:135) @ 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.executeupdate(resultsetreturnimpl.java:211) @ org.hibernate.engine.jdbc.batch.internal.nonbatchingbatch.addtobatch(nonbatchingbatch.java:62) @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:3124) @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:3581) @ org.hibernate.action.internal.entityinsertaction.execute(entityinsertaction.java:104) @ org.hibernate.engine.spi.actionqueue.executeactions(actionqueue.java:463) @ org.hibernate.engine.spi.actionqueue.executeactions(actionqueue.java:349) @ org.hibernate.event.internal.abstractflushingeventlistener.performexecutions(abstractflushingeventlistener.java:350) @ org.hibernate.event.internal.defaultflusheventlistener.onflush(defaultflusheventlistener.java:56) @ org.hibernate.internal.sessionimpl.flush(sessionimpl.java:1222) @ org.hibernate.internal.sessionimpl.managedflush(sessionimpl.java:425) @ org.hibernate.engine.transaction.internal.jdbc.jdbctransaction.beforetransactioncommit(jdbctransaction.java:101) @ org.hibernate.engine.transaction.spi.abstracttransactionimpl.commit(abstracttransactionimpl.java:177) @ org.springframework.orm.hibernate4.hibernatetransactionmanager.docommit(hibernatetransactionmanager.java:584) ... 78 more caused by: org.postgresql.util.psqlexception: no value specified parameter 1. @ org.postgresql.core.v3.simpleparameterlist.checkallparametersset(simpleparameterlist.java:223) @ org.postgresql.core.v3.queryexecutorimpl.execute(queryexecutorimpl.java:244) @ org.postgresql.jdbc2.abstractjdbc2statement.execute(abstractjdbc2statement.java:561) @ org.postgresql.jdbc2.abstractjdbc2statement.executewithflags(abstractjdbc2statement.java:419) @ org.postgresql.jdbc2.abstractjdbc2statement.executeupdate(abstractjdbc2statement.java:365) @ com.mchange.v2.c3p0.impl.newproxypreparedstatement.executeupdate(newproxypreparedstatement.java:105) @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.executeupdate(resultsetreturnimpl.java:208)
here typedef config column:
public class jsonusertype extends abstractusertype { @override public int[] sqltypes() { return new int[] { types.java_object}; } @suppresswarnings("rawtypes") @override public class returnedclass() { return string.class; } @override public object nullsafeget(resultset resultset, string[] strings, sessionimplementor sessionimplementor, object o) throws hibernateexception, sqlexception { if(resultset.getstring(strings[0]) == null){ return null; } return resultset.getstring(strings[0]); } @override public void nullsafeset(preparedstatement preparedstatement, object o, int i, sessionimplementor sessionimplementor) throws hibernateexception, sqlexception { if (o == null) { preparedstatement.setnull(i, types.other); return; } } }
and class extends:
abstract class abstractusertype implements usertype { @override public object assemble(serializable cached, object owner) { return cached; } @override public object deepcopy(object value) { return value; } @override public serializable disassemble(object value) { return (serializable)value; } @override public boolean equals(object x, object y) { return (x == y) || (x != null && y != null && (x.equals(y))); } @override public int hashcode(object x) { return x.hashcode(); } @override public boolean ismutable() { return false; } @override public object replace(object original, object target, object owner) { return original; } }
can please explain why happening? started after migrated spring 4 , hibernate 4. hibernate logs provided below seems can't bind firs parameter, can't figure out why.
insert configuration (config, id) values (?, ?) 15-dec-2014 17:16:54,594 trace [basicbinder:main] binding parameter [2] [integer] - [229] 15-dec-2014 17:16:54,595 warn [sqlexceptionhelper:main] sql error: 0, sqlstate: 22023 15-dec-2014 17:16:54,595 error [sqlexceptionhelper:main] no value specified parameter 1.
Comments
Post a Comment