-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query Parameter ordering in Hibernate 2
PostPosted: Tue Nov 16, 2004 6:21 pm 
Newbie

Joined: Tue Nov 16, 2004 6:13 pm
Posts: 2
Hibernate version:
2

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
SQL Server 2000

The generated SQL (show_sql=true):
insert into activation_details_cap (capacity_value, capacity_type, transaction_id, feature_id) values (?, ?, ?, ?)

Debug level Hibernate log excerpt:
...
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.persister.EntityPersister] Dehydrating entity: [com.embarcadero.activation.database.ActivationDetailsCap#com.embarcadero.activation.database.ActivationDetailsCapPK@1f0d7b8[capacityType=CPU,activationDetail=com.embarcadero.activation.database.ActivationDetail@18f5c10[comp_id=com.embarcadero.activation.database.ActivationDetailPK@c6145c[featureDetail=com.embarcadero.activation.database.FeatureDetail@1a5ee81[featureId=4],activation=com.embarcadero.activation.database.Activation@1b206f[transactionId=90049926-A979-46E9-BCB2-F4DF8A5F4E36]]]]]
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.StringType] binding 'UNLIMITED' to parameter: 1
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.StringType] binding 'CPU' to parameter: 2
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.IntegerType] binding '4' to parameter: 3
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.StringType] binding '90049926-A979-46E9-BCB2-F4DF8A5F4E36' to parameter: 4
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2004-11-16 16:52:11,509 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-11-16 16:52:11,509 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@1fe2d13, cl=org.jboss.mx.loading.UnifiedClassLoader3@1683cc5{ url=null ,addedOrder=0}
2004-11-16 16:52:11,525 DEBUG [net.sf.hibernate.util.JDBCExceptionReporter] SQL Exception
java.sql.SQLException: Operand type clash: int is incompatible with uniqueidentifier
at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:392)
at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:91)
at net.sourceforge.jtds.jdbc.Tds.submitProcedure(Tds.java:235)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.submitProcedure(PreparedStatement_base.java:195)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.findOrCreateProcedure(PreparedStatement_base.java:179)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(PreparedStatement_base.java:131)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeUpdate(PreparedStatement_base.java:290)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
...

I'm noticing this issue with Hibernate2. In the query, parameter values for 3 & 4 are interchanged. But the corresponding columns are not. This causes a problem since the 2 columns are not compatible.

Is there are way to control this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 16, 2004 6:22 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why didn't you supply the rest of the required information?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Re: Query Parameter ordering in Hibernate 2
PostPosted: Tue Nov 16, 2004 6:28 pm 
Newbie

Joined: Tue Nov 16, 2004 6:13 pm
Posts: 2
kartik shah wrote:
Hibernate version:
2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="com.embarcadero.activation.database.ActivationDetailsCap"
table="activation_details_cap"
>

<composite-id name="comp_id" class="com.embarcadero.activation.database.ActivationDetailsCapPK">
<key-property
name="capacityType"
column="capacity_type"
type="java.lang.String"
length="16"
/>
<!-- bi-directional many-to-one association to ActivationDetail -->
<key-many-to-one
name="activationDetail"
class="com.embarcadero.activation.database.ActivationDetail"
>
<column name="transaction_id" />
<column name="feature_id" />
</key-many-to-one>
</composite-id>

<property
name="capacityValue"
type="java.lang.String"
column="capacity_value"
not-null="true"
length="128"
/>

<!-- associations -->

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
try
{
tx = HibernateUtils.beginTransaction();
LOGGER.finest("Started transaction.");

ActivationManager manager = new ActivationManager();
Activation activation = manager.startActivation ( productInfo, machine, campaign );

if ( activation != null )
{
LicenseFile lf = new LicenseFile();
manager.serializeActivation( activation, lf );

s.setLicenseFile( lf );
s.setMessage( "Activation resolved using " + activation.getMachineAttribute().getAttributeValue() );
s.setTransactionId( activation.getTransactionId() );
s.setUserInfoUrl( ActivationResourceBundle.getStringWithArgs1( "UserInformationURL", activation.getTransactionId() ));
}

tx.commit();
}
catch ( Exception e )
{
HibernateUtils.rollbackTransaction( tx );
e.printStackTrace();

s.setMessage( e.getMessage() );
throw new ActivationRemoteException ( e.getMessage() );
}
finally
{
HibernateUtils.closeSession();
}


Full stack trace of any exception that occurs:
2004-11-16 17:23:18,741 DEBUG [net.sf.hibernate.util.JDBCExceptionReporter] SQL Exception
java.sql.SQLException: Operand type clash: int is incompatible with uniqueidentifier
at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:392)
at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:91)
at net.sourceforge.jtds.jdbc.Tds.submitProcedure(Tds.java:235)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.submitProcedure(PreparedStatement_base.java:195)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.findOrCreateProcedure(PreparedStatement_base.java:179)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(PreparedStatement_base.java:131)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeUpdate(PreparedStatement_base.java:290)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:52)
at com.embarcadero.activation.ws.ActivationServiceImpl.StartActivation(ActivationServiceImpl.java:55)
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 org.jboss.webservice.server.InvokerProviderJSE.invokeServiceEndpoint(InvokerProviderJSE.java:153)
at org.jboss.webservice.server.InvokerProvider.invokeMethod(InvokerProvider.java:347)
at org.apache.axis.providers.java.RPCProvider.invokeTarget(RPCProvider.java:177)
at org.jboss.webservice.server.InvokerProviderJSE.invokeTarget(InvokerProviderJSE.java:92)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:122)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:360)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:162)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:125)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:557)
at org.jboss.webservice.server.ServerEngine.invokeInternal(ServerEngine.java:202)
at org.jboss.webservice.server.ServerEngine.invoke(ServerEngine.java:91)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:971)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:372)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)

Name and version of the database you are using:
SQL Server 2000

The generated SQL (show_sql=true):
insert into activation_details_cap (capacity_value, capacity_type, transaction_id, feature_id) values (?, ?, ?, ?)

Debug level Hibernate log excerpt:
...
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.persister.EntityPersister] Dehydrating entity: [com.embarcadero.activation.database.ActivationDetailsCap#com.embarcadero.activation.database.ActivationDetailsCapPK@1f0d7b8[capacityType=CPU,activationDetail=com.embarcadero.activation.database.ActivationDetail@18f5c10[comp_id=com.embarcadero.activation.database.ActivationDetailPK@c6145c[featureDetail=com.embarcadero.activation.database.FeatureDetail@1a5ee81[featureId=4],activation=com.embarcadero.activation.database.Activation@1b206f[transactionId=90049926-A979-46E9-BCB2-F4DF8A5F4E36]]]]]
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.StringType] binding 'UNLIMITED' to parameter: 1
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.StringType] binding 'CPU' to parameter: 2
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.IntegerType] binding '4' to parameter: 3
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.type.StringType] binding '90049926-A979-46E9-BCB2-F4DF8A5F4E36' to parameter: 4
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2004-11-16 16:52:11,509 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2004-11-16 16:52:11,509 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-11-16 16:52:11,509 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@1fe2d13, cl=org.jboss.mx.loading.UnifiedClassLoader3@1683cc5{ url=null ,addedOrder=0}
2004-11-16 16:52:11,525 DEBUG [net.sf.hibernate.util.JDBCExceptionReporter] SQL Exception
java.sql.SQLException: Operand type clash: int is incompatible with uniqueidentifier
at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:392)
at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:91)
at net.sourceforge.jtds.jdbc.Tds.submitProcedure(Tds.java:235)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.submitProcedure(PreparedStatement_base.java:195)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.findOrCreateProcedure(PreparedStatement_base.java:179)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(PreparedStatement_base.java:131)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeUpdate(PreparedStatement_base.java:290)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
...

I'm noticing this issue with Hibernate2. In the query, parameter values for 3 & 4 are interchanged. But the corresponding columns are not. This causes a problem since the 2 columns are not compatible.

Is there are way to control this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.