Database TEXT field, java.sql.Clob, Textarea/Text problem

I have database field which is TEXT and my hibernate gets that as java.sql.Clob and in my form it is shown as a TextField.

When I do save with Form commit() method, it throws this error:
com.vaadin.data.Buffered$SourceException
at com.vaadin.ui.Form.commit(Form.java:338)

Caused by: com.vaadin.data.Buffered$SourceException
at com.vaadin.ui.AbstractField.commit(AbstractField.java:231)
at com.vaadin.ui.Form.commit(Form.java:312)
… 28 more
Caused by: com.vaadin.data.Property$ConversionException: java.lang.NoSuchMethodException: java.sql.Clob.(java.lang.String)
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:709)

Did anyone see the error ?

To recreate this problem
create table myfoo (
notes TEXT
)

public class MyFoo {
private Clob notes;
}

Create a form to display this and have save button doing the commit()

Hi!

This means that the textfield’s (textarea) data type, which is String, cannot be transformed into a Clob. You need to do this conversion yourself.

The easiest way is by introducing a getter/setter in your MyFoo class that accept String parameters and save that string into your Clob object. Another way would be to wrap MyFoo in a delegate class that contains the same string->clob logic and is used in the UI.

A third way, not requiring you to change or wrap your data object, would be to create your own kind of Property that does the conversion for you. But I think this would make for more complex code in the long run.

HTH,
/Jonatan