ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vishalj <Vish...@ivycomptech.com>
Subject Re: stored procedure in iBatis 3
Date Tue, 12 Jan 2010 05:17:19 GMT

Thanks for the reply, am a newbie ,may be am missing out on something,
This is my complete setup 



Mapping:
	<select  statementType="CALLABLE" id="storedProc" parameterType="Address"
resultType="Address">
		   {call TEST_SP(#{street},#{street,mode=OUT,jdbcType=VARCHAR})}
	</select>

Method in interface 
public Address storedProc(Address address);

Address.java
public class Address {
	
	private String street;

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

}

STORED PROCEDURE:
CREATE OR REPLACE
PROCEDURE TEST_SP
   (streetIn IN VARCHAR,streetOut OUT VARCHAR)
AS

BEGIN
  INSERT INTO TEST_ADDRESS values(1,streetIn) ;
  streetOut:=streetIn;
  commit;
END;



Plance JDBC 
   CallableStatement stmt = conn.prepareCall("call TEST_SP(?,?)");
 stmt.setString(1,"asdhk");
 stmt.registerOutParameter(2,Types.VARCHAR);
stmt.execute();
 System.out.println(stmt.getString(2));

This is my complete setup 

I can see the TEST_ADDRESS table updated . but the return type i am getting
is null when i execute this 
	Address address = new Address();
			address.setStreet("KONDAPUR");
			UserProfileMapper mapper = session.getMapper(UserProfileMapper.class);
			Address address2 = mapper.storedProc(address);	
			System.out.println("address " + address2);



Clinton Begin wrote:
> 
> You're the only one reporting this problem, but you're not the only one
> using stored procs.
> 
> Therefore, you'll have to help us out here.  Trace through the source,
> enable logging, put something together to test this out.
> 
> Clinton
> 
> On Mon, Jan 11, 2010 at 2:23 AM, vishalj <VishalJ@ivycomptech.com> wrote:
> 
>>
>> Hi Clinton,
>> I downloaded the updated version ibatis-3-core-3.0.0.220.jar and the
>> Exception is gone but there is still the stored procedure is not
>> inserting
>> any thing to the table ,added to that the return value is also null
>>
>> I changed my mapping to something like this
>>
>>        <select  statementType="CALLABLE" id="storedProc"
>> parameterType="Address"
>> resultType="Address">
>>                   {call
>> TEST_SP(#{street},#{street,mode=OUT,jdbcType=VARCHAR})}
>>        </select>
>>
>>
>> Clinton Begin wrote:
>> >
>> > I've let you know already.  It's in trunk.  Build it.  Otherwise watch
>> for
>> > the next release.
>> >
>> > On Fri, Jan 8, 2010 at 12:02 AM, vishalj <VishalJ@ivycomptech.com>
>> wrote:
>> >
>> >>
>> >> Thanks Clinton,
>> >>
>> >> Please let me know when can i use the feature i am looking for
>> >>
>> >> Regards,
>> >> Vishal
>> >>
>> >> Clinton Begin wrote:
>> >> >
>> >> > That's a bug, as per another email thread today.  It's fixed in
>> trunk
>> >> if
>> >> > you
>> >> > want to check it out and build it (one click maven/ant build)
>> >> >
>> >> > On Thu, Jan 7, 2010 at 10:16 PM, vishalj <VishalJ@ivycomptech.com>
>> >> wrote:
>> >> >
>> >> >>
>> >> >> Sorry to say , i already did try that .to mention again one of
my
>> >> second
>> >> >> parameter is out type
>> >> >>
>> >> >> but when i try with the mapping as follows :
>> >> >>        <select  statementType="CALLABLE" id="storedProc"
>> >> >> parameterType="Address">
>> >> >>                   {call TEST_SP(#(street),#(street))}
>> >> >>        </select>
>> >> >>
>> >> >> I get
>> >> >>
>> >> >>  org.apache.ibatis.builder.BuilderException: Error parsing SQL
>> Mapper
>> >> >> Configuration. Cause: java.lang.RuntimeException: Error parsing
>> Mapper
>> >> >> XML.
>> >> >> Cause: org.apache.ibatis.type.TypeException: Could not resolve
type
>> >> alias
>> >> >> 'IN'.  Cause: java.lang.ClassNotFoundException: Cannot find class:
>> IN
>> >> >>
>> >> >>
>> >> >> Please let me know if i need to do something more .Am a newbie
to
>> >> iBatis
>> >> >>
>> >> >>
>> >> >> nmaves wrote:
>> >> >> >
>> >> >> > 1) You might want to read the documentation one more time.
>> >> >> >
>> >> >> > 2)  here is your map
>> >> >> >
>> >> >> > <insert id="myProc" statementType="CALLABLE"
>> >> >> > paramaterMap="someParameterMap">
>> >> >> >     {call TEST_SP(?,?)}
>> >> >> > </insert>
>> >> >> >
>> >> >> > or with inline parameters
>> >> >> >
>> >> >> > <insert id="myProc" statementType="CALLABLE"
>> >> >> paramaterType="com.acme.Foo">
>> >> >> >     {call TEST_SP(#{bar},#{bat})}
>> >> >> > </insert>
>> >> >> >
>> >> >> > On Thu, Jan 7, 2010 at 12:09 AM, vishalj
>> <VishalJ@ivycomptech.com>
>> >> >> wrote:
>> >> >> >
>> >> >> >>
>> >> >> >> This is the JDBC proc for the same
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>                    CallableStatement stmt =
>> conn.prepareCall("call
>> >> >> >> TEST_SP(?,?)");
>> >> >> >>                    stmt.setString(1,"asdhk");
>> >> >> >>                    stmt.registerOutParameter(2,Types.VARCHAR);
>> >> >> >>                    stmt.execute();
>> >> >> >>                    System.out.println(stmt.getString(2));
>> >> >> >>
>> >> >> >> Regards,
>> >> >> >> Vishal
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> Clinton Begin wrote:
>> >> >> >> >
>> >> >> >> > Can you provide the standard JDBC code you'd use
to call your
>> >> >> >> procedure?
>> >> >> >> >
>> >> >> >> > You need to understand how JDBC calls procs, and
then it
>> becomes
>> >> >> >> > obvious.  Send the JDBC code, and I'll translate
it into a
>> >> mapping
>> >> >> for
>> >> >> >> > you.
>> >> >> >> >
>> >> >> >> > Clinton
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > On Wed, Jan 6, 2010 at 10:15 PM, vishalj
>> >> <VishalJ@ivycomptech.com>
>> >> >> >> wrote:
>> >> >> >> >>
>> >> >> >> >> It would be a great help if you can give me the
mapping for
>> >> >> >> >>
>> >> >> >> >> CREATE OR REPLACE
>> >> >> >> >> PROCEDURE TEST_SP
>> >> >> >> >>   (streetIn IN VARCHAR,streetOut OUT VARCHAR)
>> >> >> >> >> AS
>> >> >> >> >>
>> >> >> >> >> BEGIN
>> >> >> >> >>  INSERT INTO TEST_ADDRESS values(1,streetIn)
;
>> >> >> >> >>  streetOut:=streetIn;
>> >> >> >> >> END;
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> I want to pass in a Address Object and get Back
a Address
>> Object
>> >> >> Back
>> >> >> >> >> ,the
>> >> >> >> >> java Class for Address Object looks like this
>> >> >> >> >>
>> >> >> >> >> public class Address {
>> >> >> >> >>
>> >> >> >> >>        private String street;
>> >> >> >> >>
>> >> >> >> >>        public String getStreet() {
>> >> >> >> >>                return street;
>> >> >> >> >>        }
>> >> >> >> >>
>> >> >> >> >>        public void setStreet(String street) {
>> >> >> >> >>                this.street = street;
>> >> >> >> >>        }
>> >> >> >> >>
>> >> >> >> >> }
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> Clinton Begin wrote:
>> >> >> >> >> >
>> >> >> >> >> > Yes, stored procs are mapped exactly like
every other
>> >> statement
>> >> >> in
>> >> >> >> >> iBATIS
>> >> >> >> >> > 3,
>> >> >> >> >> > but you set the statementType attribute
to CALLABLE.
>> >> >> >> >> >
>> >> >> >> >> > Page 22 discusses this a little (although
I agree, not
>> >> enough).
>> >> >> >> >> >
>> >> >> >> >> > <insert id="myProc" statementType="CALLABLE">
>> >> >> >> >> > {your java proc call here - same syntax
as JDBC}
>> >> >> >> >> > </insert>
>> >> >> >> >> >
>> >> >> >> >> > Parameters can still be set to IN, OUT or
INOUT.
>> >> >> >> >> >
>> >> >> >> >> > We've eliminated the <procedure> element,
as it wasn't
>> >> >> descriptive
>> >> >> >> >> enough.
>> >> >> >> >> >
>> >> >> >> >> > Clinton
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> > On Wed, Jan 6, 2010 at 12:06 AM, vishalj
>> >> >> <VishalJ@ivycomptech.com>
>> >> >> >> >> wrote:
>> >> >> >> >> >
>> >> >> >> >> >>
>> >> >> >> >> >> How do i map  execute Stored Procedures
in DB for iBatis
>> >> 3.The
>> >> >> >> >> >> documentation
>> >> >> >> >> >> does not talk about that
>> >> >> >> >> >> --
>> >> >> >> >> >> View this message in context:
>> >> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27026799.html
>> >> >> >> >> >> Sent from the iBATIS - User - Java mailing
list archive at
>> >> >> >> Nabble.com.
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> >> >> >> To unsubscribe, e-mail:
>> >> user-java-unsubscribe@ibatis.apache.org
>> >> >> >> >> >> For additional commands, e-mail:
>> >> >> user-java-help@ibatis.apache.org
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >> --
>> >> >> >> >> View this message in context:
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27052357.html
>> >> >> >> >> Sent from the iBATIS - User - Java mailing list
archive at
>> >> >> Nabble.com.
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> >> >> To unsubscribe, e-mail:
>> user-java-unsubscribe@ibatis.apache.org
>> >> >> >> >> For additional commands, e-mail:
>> >> user-java-help@ibatis.apache.org
>> >> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> >> > To unsubscribe, e-mail:
>> user-java-unsubscribe@ibatis.apache.org
>> >> >> >> > For additional commands, e-mail:
>> user-java-help@ibatis.apache.org
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >>
>> >> >>
>> >>
>> http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27055894.html
>> >> >> >> Sent from the iBATIS - User - Java mailing list archive
at
>> >> Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> >> >> >> For additional commands, e-mail:
>> user-java-help@ibatis.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27071488.html
>> >> >> Sent from the iBATIS - User - Java mailing list archive at
>> Nabble.com.
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> >> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27072029.html
>> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27107708.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/stored-procedure-in-iBatis-3-tp27026799p27122794.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message