Obtain the document number through OracleFunction in Hibernate

Source: Internet
Author: User
Today, we encountered an OracleFunction problem when using the Hibernate Development Project. During the project development, all document numbers are generated using a Function.

Today, we encountered an Oracle Function problem when using the Hibernate Development Project. During the project development, all document numbers are generated using a Function.

Today, we encountered an Oracle Function problem when using the Hibernate development project.

During project development, all document numbers are generated using a Function. this Function has some DML syntax, so you cannot use select fun _... () Into v_ref from dual method to obtain the returned result.

After querying the relevant information, Hibernate requires that a cursor be returned when executing Procedure and Function. Therefore, we can add another Function processing method as a work und.

A new Function is defined as follows:

Function fun_get_vou_web (....)

RETURN SYS_REFCURSOR

As

V_vou varchar2 (20 );

St_cursor SYS_REFCURSOR;
BEGIN
V_vou: = fun_get_vou (....);

OPEN st_cursor
SELECT v_vou as vouno from dual;

RETURN st_cursor;

END;

Then configure in hbm. xml:



{? = Call fun_get_vou_web (.......)}

Finally, you can query the execution result of getNewAppNo in java.

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.