Solution for saving Oracle clob fields using hibernate

Source: Internet
Author: User

Note: This article is original. You are welcome to reprint it. Reprinted please indicate the source: http://blog.csdn.net/techyang

Session session = hibernateutil. currentsession (); // create a session
Hibernateutil. begintransaction (); // start the transaction
Umovieinfo. setcontent (hibernate. createclob (""); // this step is important. Note that the quotation marks contain spaces rather than empty strings.
Session. Save (umovieinfo); // save data
Session. Flush ();
Session. Refresh (umovieinfo, lockmode. Upgrade );

// Assign a value to the clob Field
Java. SQL. clob clobcontent = (Java. SQL. clob) umovieinfo. getcontent ();
Clobcontent. setstring (1, "Super long string..."); // assign a value to the clob field again
Hibernateutil. Commit (); // submit the transaction

The following fields are defined in the entity of umovieinfo:
Private clob content;

The HBM file is defined as follows:
<Property name = "content" type = "clob">
<Column name = "content"/>
</Property>

After this operation, you can solve the error of "error org. hibernate. util. jdbcexceptionreporter-ORA-01461: Can only assign values to long values inserted in long columns"

Related Article

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.