JPA Arrays

JPA defines support the persistence of arrays but only arrays of byte[], Byte[], char[], Character[]. Moreover it only defines support for persisting these arrays into CLOB columns, hence they have to be byte-streamed. Namely

  • Single Column - the array is byte-streamed into a single column in the table of the containing object.

Single Column Arrays

Let's suppose you have a class something like this

So we have an Account and it has a number of permissions, each expressed as a byte. We want to persist the permissions in a single-column into the table of the account (but we don't want them serialised). We then define MetaData something like this

<entity class="Account">
    <table name="ACCOUNT"/>
        <basic name="permissions">
            <column name="PERMISSIONS"/>

This results in a datastore schema as follows

See also :-