Re: Oracle ref cursors

104 views
Skip to first unread message

Eduardo Macarron

unread,
Apr 13, 2013, 1:15:17 AM4/13/13
to mybatis-user
Wes, can you describe what happens? Any error? Can you post the
stacktrace then? Also, posting one of your mappers will be helpful.

2013/4/13 Wes Miller <atssecu...@gmail.com>:
>
>
> 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

unread,
Apr 19, 2013, 6:30:40 PM4/19/13
to mybati...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages