ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel H. F. e Silva" <d...@yahoo.com>
Subject RE: Mapping Problem
Date Fri, 04 Feb 2005 13:31:25 GMT
Hehe, 

 That was not exactly my intention, but if it worked for you, nice!
 I just meant to take your OFFENCES_SEQ.NEXTVAL and put it in place of #id# at values list.
 But, it is working!

Cheers,
 Daniel Silva.

--- Ben Gill <ben.gill@ocado.com> wrote:

> Thanks Daniel, that works...
> 
> Seems strange to me though that it does, as surely the selectKey would have
> set id to a java.lang.String anyhow...
> 
> Working:
> 
> <typeAlias alias="offence"
> type="com.ocado.tracker.offences.forms.OffenceForm"/>
>     
> 	<insert id="addOffence" parameterClass="offence">
> 		
> 
>         insert into 
>         OFFENCES (OFFENCE_UUID, STATUS, AUTHORITY, TICKET_NUMBER, 
> 		  OFFENCE, 
> 		  EMPLOYEE_UUID, DATETIME_OF_OFFENCE, DATETIME_OF_TICKET, 
> 		  SITE, FLEET_UUID, LOC_OF_OFFENCE, POSTCODE, FINE,
> ORDER_NUMBER,
> 		  ROUTE_ID, ENTERED_BY, ASSIGNED_TO, LAST_MODIFIED_BY,
> LAST_MODIFIED, 
> 		  CREATION_DATE) 
> 	values (
>         <selectKey resultClass="java.lang.String" keyProperty="id" >
> 			SELECT OFFENCES_SEQ.NEXTVAL AS ID FROM DUAL
> 		</selectKey>, 'new', #authority#, #ticketNumber#, #offence#,
> 		#employeeID#, to_date(#dateOfOffence#,'dd/mm/YYYY HH24:mi'),
> 		to_date(#dateOfTicket#,'dd/mm/YYYY HH24:mi'),
> 		#site#, #fleetID#, #locOfOffence#, #postcode#, #fine#,
> 		#orderNumber#, #routeID#, #enteredBy#, #assignedTo#,
> sysdate, sysdate);
>     </insert>
> 
> Not working:
> 
> <typeAlias alias="offence"
> type="com.ocado.tracker.offences.forms.OffenceForm"/>
>     
> 	<insert id="addOffence" parameterClass="offence">
> 
> 		<selectKey resultClass="java.lang.String" keyProperty="id" >
> 			SELECT OFFENCES_SEQ.NEXTVAL AS ID FROM DUAL
> 		</selectKey>		
> 
>         insert into 
>         OFFENCES (OFFENCE_UUID, STATUS, AUTHORITY, TICKET_NUMBER, 
> 		  OFFENCE, 
> 		  EMPLOYEE_UUID, DATETIME_OF_OFFENCE, DATETIME_OF_TICKET, 
> 		  SITE, FLEET_UUID, LOC_OF_OFFENCE, POSTCODE, FINE,
> ORDER_NUMBER,
> 		  ROUTE_ID, ENTERED_BY, ASSIGNED_TO, LAST_MODIFIED_BY,
> LAST_MODIFIED, 
> 		  CREATION_DATE) 
> 	values (
>         #id#, 'new', #authority#, #ticketNumber#, #offence#,
> 		#employeeID#, to_date(#dateOfOffence#,'dd/mm/YYYY HH24:mi'),
> 		to_date(#dateOfTicket#,'dd/mm/YYYY HH24:mi'),
> 		#site#, #fleetID#, #locOfOffence#, #postcode#, #fine#,
> 		#orderNumber#, #routeID#, #enteredBy#, #assignedTo#,
> sysdate, sysdate);
>     </insert>
> 
> Thanks anyhow...
> 
> -----Original Message-----
> From: Daniel H. F. e Silva [mailto:dhfs@yahoo.com]
> Sent: 04 February 2005 12:39
> To: ibatis-user-java@incubator.apache.org
> Subject: RE: Mapping Problem
> 
> 
> Ben,
> 
>  Seems to me that you're using a sequence that gives you integer values,
> aren't you?
>  So, why does your pk column has type VARCHAR(20)?
>  If your database is Oracle, i bet the problem is happening due to
> converting an integer to a
> string and then back.
>  What happens if you replace your #id# in the VALUES list with the call of
> the sequence?
> 
> Cheers,
>  Daniel Silva.
>  
> 
> --- Ben Gill <ben.gill@ocado.com> wrote:
> 
> > Yeah I tried that... in fact I have tried a whole nuch of things but
> cannot
> > get it to work!!
> > 
> > I am now using:
> > 
> > <typeAlias alias="offence"
> > type="com.ocado.tracker.offences.forms.OffenceForm"/>
> >     
> > 	<insert id="addOffence" parameterClass="offence">
> > 		<selectKey resultClass="java.lang.String" keyProperty="id" >
> > 			SELECT OFFENCES_SEQ.NEXTVAL AS ID FROM DUAL
> > 		</selectKey>
> > 
> >         insert into 
> >         OFFENCES (OFFENCE_UUID, STATUS, AUTHORITY, TICKET_NUMBER, 
> > 		  OFFENCE, 
> > 		  EMPLOYEE_UUID, DATETIME_OF_OFFENCE, DATETIME_OF_TICKET, 
> > 		  SITE, FLEET_UUID, LOC_OF_OFFENCE, POSTCODE, FINE,
> > ORDER_NUMBER,
> > 		  ROUTE_ID, ENTERED_BY, ASSIGNED_TO, LAST_MODIFIED_BY,
> > LAST_MODIFIED, 
> > 		  CREATION_DATE) 
> > 	values (#id#, 'new', #authority#, #ticketNumber#, #offence#,
> > 		#employeeID#, to_date(#dateOfOffence#,'dd/mm/YYYY HH24:mi'),
> > 		to_date(#dateOfTicket#,'dd/mm/YYYY HH24:mi'),
> > 		#site#, #fleetID#, #locOfOffence#, #postcode#, #fine#,
> > 		#orderNumber#, #routeID#, #enteredBy#, #assignedTo#,
> > sysdate, sysdate);
> >     </insert>
> > 
> > org.springframework.jdbc.UncategorizedSQLException: (SqlMapClient
> > operation): en
> > countered SQLException [
> > --- The error occurred in
> com/ocado/tracker/offences/dao/sql/OffenceSQL.xml.
> > --- The error occurred while applying a parameter map.
> > --- Check the addOffence-InlineParameterMap.
> > --- Check the parameter mapping for the 'id' property.
> > --- Cause: java.sql.SQLException: Invalid column type]; nested exception
> is
> > com.
> > ibatis.common.jdbc.exception.NestedSQLException:
> > --- The error occurred in
> com/ocado/tracker/offences/dao/sql/OffenceSQL.xml.
> > --- The error occurred while applying a parameter map.
> > --- Check the addOffence-InlineParameterMap.
> > --- Check the parameter mapping for the 'id' property.
> > --- Cause: java.sql.SQLException: Invalid column type
> > com.ibatis.common.jdbc.exception.NestedSQLException:
> > --- The error occurred in
> com/ocado/tracker/offences/dao/sql/OffenceSQL.xml.
> > --- The error occurred while applying a parameter map.
> > --- Check the addOffence-InlineParameterMap.
> > --- Check the parameter mapping for the 'id' property.
> > --- Cause: java.sql.SQLException: Invalid column type
> > Caused by: java.sql.SQLException: Invalid column type
> >         at
> > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUp
> > date(GeneralStatement.java:86)
> >         at
> > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExe
> > cutorDelegate.java:500)
> >         at
> > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionI
> > mpl.java:89)
> > 
> > -----Original Message-----
> > From: Aitor Imaz [mailto:aitor.imaz@gmail.com]
> > Sent: 04 February 2005 12:19
> > To: ibatis-user-java@incubator.apache.org
> > Subject: Re: Mapping Problem
> > 
> > 
> > I can see one thing, in your <selectKey> the resultClass attribute 
> > should be a String if I'm not wrong. You should put there the class of 
> > the primary key returned, not of the object itself. Maybe that's the 
> > cause of the error (the selectkey mapping)?
> > 
> > Hope it helps,
> > Aitor
> > 
> > 
> > _____________________________________________________________________
> > This message has been checked for all known viruses by the 
> > MessageLabs Virus Control Centre.
> > 
> > This message has been checked for all known viruses by the MessageLabs
> Virus Control Centre.
> > 
> > 	
> > *********************************************************************
> > 
> > Notice:  This email is confidential and may contain copyright material of
> Ocado Limited (the
> > "Company"). Opinions and views expressed in this message may not
> necessarily reflect the
> > opinions and views of the Company.
> > If you are not the intended recipient, please notify us immediately and
> delete all copies of
> > this message. Please note that it is your responsibility to scan this
> message for viruses.
> > 
> > Company reg. no. 3875000.
> > Ocado Limited
> > Titan Court
> > 3 Bishops Square
> > Hatfield Business Park
> > Hatfield
> > Herts
> > AL10 9NE
> > 
> > 
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


Mime
View raw message