From: grimmel97 <grimme...@gmail.com>
Date: Tue, 9 Oct 2012 05:58:04 -0700 (PDT)
Local: Tues, Oct 9 2012 8:58 am
Subject: Re: How to Pass Java List of POJO to Oracle Stored Procedure using MyBatis?
Thank you so much for your time and help. I have finally managed to get my You have been a life saver!! Kind regards. On Tuesday, 9 October 2012 02:03:48 UTC+11, AntPort wrote:
> I made a mistake: Line #{returnValue,mode=OUT,jdbcTypeName=NUMERIC,javaType=java.lang.Integer} > Dana subota, 6. listopada 2012. 23:35:44 UTC+2, korisnik AntPort napisao >> 1.Type handler must be defined for every parameter. Here is one example: >> <select id="callMyProcedure" statementType="CALLABLE" >> 2. No. Only if you use same type handler for IN and OUT parameters. >> Dana petak, 5. listopada 2012. 16:30:47 UTC+2, korisnik grimmel97 napisao >>> Hi, >>> Thank you again for your time in trying to explain this to me. I will >>> 1. If I have to create a TypeHandler for each of my parameters, then in >>> Param1TypeHandler >>> Param2TypeHandler >>> Param3TypeHandler >>> Can I specify more than one TypeHandler for the MyBatis SQLMap? >>> <update id="callOracleSP" statementType="CALLABLE" typeHandler="Param1TypeHandler,Param2TypeHandler,Param3TypeHAndler"> >>> ) >>> 2. I am actually returning a single Integer value from an OUT parameter >>> 3. Yes, I am using the older Oracle jdbc driver, so will upgrade it in >>> Thank you so much for your time. I will try and write a single type >>> On Friday, 5 October 2012 16:09:11 UTC+10, AntPort wrote: >>>> 1. Yes, you have to implement TypeHandler<T> interface. >>>> public interface TypeHandler<T> { >>>> public void setParameter(PreparedStatement ps, int i, T parameter, >>>> public T getResult(ResultSet rs, String columnName) >>>> public T getResult(CallableStatement cs, int columnIndex) >>>> } >>>> If you are not returning anything from your procedure, you can leave >>>> 2. No, you have to do something like this: >>>> IdReservation >>>> ...then you have to do something like this: >>>> List<Map<String,Object>> listOfPojoMaps = new >>>> // keys correspond to the properties of the I_RESERVATION_TYPE >>>> pojoMap.put("ID_RESERVATION",pojo.getIdReservation); >>>> listOfPojoMaps.add(pojoMap); >>>> The listOfPojoMaps is the property you set as an input parameter in >>>> 3. Every map from the listOfPojoMaps creates one STRUCT object. Since >>>> 4. In essence, yes, you will have to create typeHandler for your every >>>> public class StoredProcedurePojo { >>>> private ArrayList<LinkedHashMap<String, Object>> listOfPojoMaps; >>>> //getters / setters >>>> } >>>> You can send this wrapper as an input parameter to your typeHandler but >>>> StoredProcedurePojo wrapperPojo = (StoredProcedurePojo) >>>> List<LinkedHashMap<String,Object>> inParams = >>>> STRUCT[] structArray = new STRUCT[inParams.size()]; >>>> 5. Regarding the compiler errors....Are you using oracle.sql.STRUCT >>>> P.S. >>>> *It is important that you use ojdbc6 oracle driver, ojdbc14 doesn't >>>> Dana petak, 5. listopada 2012. 03:16:00 UTC+2, korisnik grimmel97 >>>>> Thank you AntPort for taking the time to reply. Apologies for the >>>>> 1. When I create the TypeHandler, do I just implement the MyBatis >>>>> 2. I can't get my head around the code-listing you have in the >>>>> IdReservation >>>>> and my application creates and populates a list of IReservation: >>>>> 3. Could you explain why the STRUCT[] array is required? Is that >>>>> 4. Are you saying that I would have to create a TypeHandler for each >>>>> Many thanks. >>>>> On Wednesday, 3 October 2012 11:55:06 UTC+10, grimmel97 wrote: >>>>>> Hi, >>>>>> I have been googling this for a while and cannot seem to find any >>>>>> I have an Oracle stored procedure that has a number of in parameters >>>>>> *Declared in the pacakge:* >>>>>> *Procedure:* >>>>>> On the java side, I have 3 corresponding POJO objects representing >>>>>> If so, how would the SQLMap be written? Or do I need to write more >>>>>> Thanks in advance. You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||