Question

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:

| MY_FIELD   | blob         | YES  |     | NULL    |                |

Any clues on getting this to work?

Was it helpful?

Solution

This is a bug in OpenJPA, introduced by OPENJPA-740. I've opened a bug report on your behalf: OPENJPA-1870.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top