BlobJpaEmbeddable

A utility class to enable the persisting of Blob s.

Although JPA supports custom value types, these can only be for simple values; seeeclipse-ee4j/jpa-api/issues/105.

EclipseLink does provide its own extension,Transformation API, but there’s a lot of boilerplate involved even so.

This class provides support for an alternative approach, where the Causeway Blob is marshalled in and out of this class.

Example usage:

    @Embedded
    private BlobJpaEmbeddable pdf;

    @Property()
    @PropertyLayout()
    public Blob getPdf() {
        return BlobJpaEmbeddable.toBlob(pdf);
    }
    public void setPdf(final Blob pdf) {
        this.pdf = BlobJpaEmbeddable.fromBlob(pdf);
    }

Lastly; note that javax.persistence.AttributeOverrides and javax.persistence.AttributeOverride provide a standardised way of fine-tuning the column definitions.

API

BlobJpaEmbeddable.java
class BlobJpaEmbeddable {
  BlobJpaEmbeddable fromBlob(Blob blob)     (1)
  Blob toBlob(BlobJpaEmbeddable blobJpaEmbeddable)     (2)
  Blob asBlob()
  String toString()
  boolean equals(Object o)
  int hashCode()
}
1 fromBlob(Blob)

Factory method to marshall a Blob into a BlobJpaEmbeddable

2 toBlob(BlobJpaEmbeddable)

Reciprocal method to marshall a BlobJpaEmbeddable into a Blob

Members

fromBlob(Blob)

Factory method to marshall a Blob into a BlobJpaEmbeddable

toBlob(BlobJpaEmbeddable)

Reciprocal method to marshall a BlobJpaEmbeddable into a Blob