JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.2 | Persistence | JDO ORM | JPA ORM | Runtime | JDO Runtime | JPA Runtime | Extensions | Developer
O/R Mapping
Relationships
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"/>
    <attributes>
        ...
        <basic name="permissions">
            <column name="PERMISSIONS"/>
            <lob/>
        </basic>
        ...
    </attributes>
</entity>

This results in a datastore schema as follows

See also :-