Hi
I get the error "java.sql.SQLException: Parameter index out of range (3 > 2)." when i try to save the code below, is there something missing from the many-to-one or one-to-many tag, i have tried cascade and it still doesnt work, it seems that it does not like the many-to-one tag in DDETAILS, because when i take that out it saves correctly, any ideas?
Hibernate version:2.1.3
Mapping documents:
<!--DDETAILS MAPPING-->
<hibernate-mapping>
<class name="DDetails" table="d_details">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>
<property name="value" column="value" not-null="false"/>
<property name="filesInID" column="filesin_id" not-null="false"/>
<many-to-one name="dEpFilesIn" class="DEpFilesIn" column="filesin_id" not-null="false" cascade="all"/>
</class>
</hibernate-mapping>
<!--DEPFILESIN Mapping-->
<hibernate-mapping>
<class name="DEpFilesIn" table="d_epfilesin">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>
<property name="fromId" column="from_id" not-null="true"/>
<bag name="dDetails" inverse="true" lazy="true" cascade="all">
<key column="filesin_id"/>
<one-to-many class="DDetails"/>
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
DDetails dDetailsObj = (DDetails)it.next();
dDetailsObj.setId(null);
myMachineSession.save(dDetailsObj);
myMachineSession.flush();
myMachineTX.commit();
Full stack trace of any exception that occurs:
java.sql.SQLException: Parameter index out of range (3 > 2).
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1967)
at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:522)
at net.sf.hibernate.type.LongType.set(LongType.java:28)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:45)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:30)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:33)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:361)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:471)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:719)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:607)
at XMLTest.getQuery(XMLTest.java:97)
at XMLTest.main(XMLTest.java:239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
java.sql.SQLException: Parameter index out of range (16 > 15).
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1967)
at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:522)
at net.sf.hibernate.type.LongType.set(LongType.java:28)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:45)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:30)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:33)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:361)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:471)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:719)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:607)
at XMLTest.getQuery(XMLTest.java:97)
at XMLTest.main(XMLTest.java:239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
rethrown as net.sf.hibernate.JDBCException: Could not insert: Parameter index out of range (16 > 15).
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:722)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:607)
at XMLTest.getQuery(XMLTest.java:97)
at XMLTest.main(XMLTest.java:239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.sql.SQLException: Parameter index out of range (16 > 15).
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1967)
at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:522)
at net.sf.hibernate.type.LongType.set(LongType.java:28)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:45)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:30)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:33)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:361)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:471)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:719)
... 8 more
Name and version of the database you are using:
Debug level Hibernate log excerpt:
|