Hibernate 4.1.2.FINAL Disabling context-sensitive LOB creation as the createClob () method triggered an error, Blob field

I want to create a blob field with hibernate / postgresql 9.1.1

Why I see this message in the logs:

INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-5)
HHH000424: Disabling contextual LOB creation as createClob() method threw error : 
java.lang.reflect.InvocationTargetException

I know this is not a mistake.

Hibernate 4.1 Documentation:

"@Lob indicates that the property should be persisted in a Blob or a Clob depending
on the property type: java.sql.Clob, Character[], char[] and java.lang.String will be
persisted in a Clob. java.sql.Blob, Byte[], byte[] and Serializable type will be persisted in a Blob."

I declare my field as follows:

@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@Basic(fetch=javax.persistence.FetchType.LAZY)
@Column(name = "`ACTA_CERTIFICACION`")
public byte[] getActacertificacion() {
    return actacertificacion;
}
/**
 * @param actacertificacion
 * @uml.property  name="actacertificacion"
 */
public void setActacertificacion(byte[] actacertificacion) {
    this.actacertificacion = actacertificacion;
}

But in the database, it is created as a text field:

"ACTA_INCREMENTOSUSTITUCION" text

What can I do ?, I want to create a byte field or something like that.

+3
source share
1 answer

Since you are using textthe database, you must use the type CLOBin the POJO class. If you want to map this, just add the property to your POJO, as shown below,

@Column(name="ACTA_INCREMENTOSUSTITUCION")
@Clob
private Clob tect;

, , Clob [], ..

+4

All Articles