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"