ClobJpaEmbeddable

A utility class to enable the persisting of Clob 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 Clob is marshalled in and out of this class.

Example usage:

    @Embedded
    private ClobJpaEmbeddable xml;

    @Property()
    @PropertyLayout()
    public Clob getXml() {
        return ClobJpaEmbeddable.toClob(xml);
    }
    public void setPdf(final Clob xml) {
        this.xml = ClobJpaEmbeddable.fromClob(xml);
    }

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

API

ClobJpaEmbeddable.java
class ClobJpaEmbeddable {
  ClobJpaEmbeddable fromClob(Clob clob)     (1)
  Clob toClob(ClobJpaEmbeddable clobJpaEmbeddable)     (2)
  Clob asClob()
  String toString()
  boolean equals(Object o)
  int hashCode()
}
1 fromClob(Clob)

Factory method to marshall a Clob into a ClobJpaEmbeddable

2 toClob(ClobJpaEmbeddable)

Reciprocal method to marshall a ClobJpaEmbeddable into a Clob

Members

fromClob(Clob)

Factory method to marshall a Clob into a ClobJpaEmbeddable

toClob(ClobJpaEmbeddable)

Reciprocal method to marshall a ClobJpaEmbeddable into a Clob