Search code examples
h2ormliteclob

h2,ormlite CLOB<->String Conversion


I need to store a long string value with h2. How can I do this? When i'm trying to insert a long string an exception is thrown which says that the values is to long "CONTENT VARCHAR(255): "STRINGDECODE...".

I read that CLOB should be used but i dont have any idea how to use it right.

How does the table definition need to look like? At the moment I'm simply using a String declaration.

@DatabaseField
String content;

And how could i convert a String to a CLOB and can I stil use the String content; declaration? Or is there a possibility to raise the VARCHAR size to the maximum?


Solution

  • I need to store a long string value with h2. How can I do this?

    ORMLite has a long-string type which persists data using the LONGVARCHAR JDBC type.

    How does the table definition need to look like?

    Something like:

    @DatabaseField(dataType = DataType.LONG_STRING)
    String content;