Open JPA - column definition binary
I'm trying to set the type of a column in OpenJPA as binary(5) so I'm using the following declaration:
@Column(name="MY_FIELD", columnDefinition="BINARY(5)")
public byte[] getMyField() {
return myField;
}
However, the column is always created as a blob:
| M开发者_运维百科Y_FIELD | blob | YES | | NULL | |
Any clues on getting this to work?
This is a bug in OpenJPA, introduced by OPENJPA-740. I've opened a bug report on your behalf: OPENJPA-1870.
The Hibernate doc says the @Lob annotation is to be used :
@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.
It works nicely with Hibernate: it should be ok for you with OpenJPA, since the documentation says @Lob is handled "in a standard JPA manner".
精彩评论