convert String to Clob and vice versa in Hibernate -


suppose have class:

class eventtransaction {     .....     private clob dataxml;      public clob getdataxml() {        return dataxml;     }      public void setdataxml(clob dataxml) {        this.dataxml = dataxml;     } } 

and hibernate mapping xml:

 <property name="dataxml" type="java.sql.clob">         <column name="xml" sql-type="clob"/>  </property> 

in java code, how convert string clob , vice versa save database:

ex: eventtransaction et = new eventtransaction();     string xml = "fdfsafafafa";     et.setdataxml(convertstringtoclob(xml));     hibernatetemplate.saveorupdate(et); 

could please how implement function convertstringtoclob(string data);

thanks,

do this

@column(name='xml') @lob private string dataxml;  public string getdataxml() {    return dataxml; }  public void setdataxml(string dataxml) {    this.dataxml = dataxml; } 

so there no need convert, , done hibernate.

i showed using annotations, same thing can done using .hbm.xml files.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -