-->
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.  [ 2 posts ] 
Author Message
 Post subject: Polymorphic mapping: Parameter index out of range
PostPosted: Tue May 03, 2005 1:41 pm 
Beginner
Beginner

Joined: Wed Dec 17, 2003 2:54 pm
Posts: 26
Location: Oslo, Norway
Hibernate version: 3.0.2

Mapping documents:

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
<class
name="foo.model.Binding"
table="bindings"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
discriminator-value="null"
where="active='Y'"
>

<id
name="BID"
column="bID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="increment">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Binding.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<discriminator
column="type"
type="string"
length="1"
/>

<property
name="active"
type="char"
update="true"
insert="true"
access="property"
column="active"
not-null="true"
/>

<property
name="created"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="created"
/>

<property
name="fromDate"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="from_date"
not-null="false"
/>

<property
name="ordreID"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="ordreID"
not-null="false"
/>

<property
name="refPTR"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="refPTR"
not-null="false"
/>
<property
name="toDate"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="to_date"
not-null="false"
/>

<many-to-one
name="user"
class="foo.model.User"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="userID"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Binding.xml
containing the additional properties and place it in your merge dir. -->
<subclass
name="foo.model.Terminal"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="D"
>

<set
name="lineBindings"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
where="active='Y'"
>

<key
column="refPTR"
>
</key>

<one-to-many
class="no.telio.model.LineBinding"
/>

</set>

<property
name="mac"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="mac"
not-null="false"
/>

<property
name="productCode"
type="java.lang.String"
:
update="true"
insert="true"
access="property"
column="product_code"
not-null="false"
/>

<property
name="serial"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="sn"
not-null="false"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Terminal.xml
containing the additional properties and place it in your merge
dir.
-->

</subclass>
<subclass
name="foo.model.AbstractLineBinding"
dynamic-update="false"
dynamic-insert="false"
>

<many-to-one
name="number"
class="foo.model.Number"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="number"
/>

<subclass
name="foo.model.LineBinding"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="N"
>

<property
name="password"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="password"
not-null="false"
/>

<property
name="rank"
type="java.lang.Short"
update="true"
insert="true"
access="property"
column="rank"
not-null="false"
/>

<set
name="swapOrders"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
where="active='Y'"
>
<key
column="refPTR"
>
</key>

<one-to-many
class="foo.model.SwapOrder"
/>

</set>

<many-to-one
name="terminal"
class="foo.model.Terminal"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="refPTR"
not-null="false"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-LineBinding.xml
containing the additional properties and place it in your merge
dir.
-->

</subclass>
</subclass>
</class>
</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():
Spring generated. The code that makes things barf is:
LineBinding newnumber = new LineBinding();
newnumber.setActive('Y');
(initialization of object properties omitted. bID is not initialized, therefore is null)
getTerminal().addBinding(newnumber);
Which causes the sql just below.

Full stack trace of any exception that occurs:
Hibernate: insert into bindings (active, created, from_date, ordreID, to_date, userID, number, password, rank, refPTR, type, bID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'N', ?)
log4j:WARN No appenders could be found for logger (org.hibernate.util.JDBCExceptionReporter).
log4j:WARN Please initialize the log4j system properly.
org.springframework.jdbc.UncategorizedSQLException: (HibernateTemplate): encountered SQLException [Parameter index out of range (12 > 11).]; nested exception is java.sql.SQLException: Parameter index out of range (12 > 11).
java.sql.SQLException: Parameter index out of range (12 > 11).
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2001)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2030)
at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:543)
at org.hibernate.type.LongType.set(LongType.java:40)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1618)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1584)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1840)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2190)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:309)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:470)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:401)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:256)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:606)
(...)

Name and version of the database you are using:
Mysql 4.0.20 (old because of our production system, not in my control)

The generated SQL (show_sql=true):
See above.

I have probably mapped myself totally off the beaten track. I need help finding a sensible way to take this further. Is there any way I can get hold of the parameter values Hibernate tries to map into the above SQL statement?

Before anyone jumps all over me: I have looked in the documentation without finding something that looks relevant. That is probably because I don't know what I am doing. That is also why I am asking for help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 1:43 pm 
Beginner
Beginner

Joined: Wed Dec 17, 2003 2:54 pm
Posts: 26
Location: Oslo, Norway
Oh, and the message about log4j not being initialized is weird, because I sure as hell am getting other log4j / commons logging output:

005-05-03 19:23:41,853 DEBUG [main] hibernate.SpringInterceptor (SpringInterceptor.java:93) - Unhandled bean foo.model.PhyDev requested, handled beans are {foo.model.Terminal=terminalInstance, foo.model.LineBinding=lineBindingInstance}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.