Here is an example.
Stored procedure:
CREATE OR REPLACE PROCEDURE getAllContacts
(
rcResult OUT SYS_REFCURSOR
)
is
mycurs sys_refcursor;
BEGIN
OPEN mycurs FOR
select * from contact
order by lastname, firstname;
rcResult := mycurs;
END;
Mapper.xml:
<select statementType="CALLABLE" id="getAllContacts"
resultMap="contactMap" >
{ call
getAllContacts(
#{resultSet, jdbcType=CURSOR, mode=OUT,
resultMap=contactMap}
)}
</select>
Mapper.java:
void getAllContacts(Contact contact);
Contact.java:
private List<Contact> resultSet = null;
... and all other fields that describe a contact
Test.java:
Contact contact = new Contact();
List<Contact> contacts = mapper.getAllContacts(contact);
for (Contact c: contact.getResultSet())
{
log.info("Contact name: " + c.getFirstName() + " " +
c.getLastName());
}
On 4/12/2013 6:01 PM, Wes Miller wrote:
> We are having issues using Oracle Database Ref Cursors in MyBatis.
> Originally, we built our application to use MyBatis to connect to our
> SQL Server 2008 database. We just finished the DB conversion to Oracle
> but we are having many issues trying to get the stored procedures syntax
> in MyBatis to work with the Oracle database. Does anybody know of any
> experts or companies that support MyBatis that are available and willing
> to hand-hold us to resolve our issues? We are willing to pay for
> support if necessary.
>
> * MyBatis 3.x
> * Oracle 11g
> * Java 1.7
> * Spring 3.2
>
> We have determined that Oracle is executing and returning a ref cursor.
> The question is what do you do next? Note: we have 50-60 procedures that
> work fine in SQL Server, but the same mapper configuration doesn�t work
> when calling Oracle procedures. I can provide code samples as requested.
>
> Please, no recruiters.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
mybatis-user...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Guy Rouillier