2012-05-01 1 views
3

Je veux créer un champ BLOB avec mise en veille prolongée/postgresql 9.1.1Mise en veille prolongée 4.1.2.FINAL méthode création LOB Désactivation contextuelle comme createClob() a jeté erreur, champ Blob

Pourquoi je vois ce message dans les journaux :

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 

Je sais que ce n'est pas une erreur.

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." 

Je déclare mon champ comme ceci:

@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; 
} 

Mais dans la base de sa création comme un champ texte:

"ACTA_INCREMENTOSUSTITUCION" text 

Que puis-je faire ?, Je veux créer un champ d'octets ou quelque chose de similaire.

Répondre

4

Étant donné que vous utilisez text dans la base de données, vous devez utiliser le type CLOB dans la classe POJO. Si vous voulez mapper cela, il suffit d'ajouter une propriété dans votre POJO comme ci-dessous,

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

Maintenant, selon vos besoins, vous pouvez convertir cette Clob à un comme dit hereoctet [].

Questions connexes