Questo contenuto non è disponibile nella lingua selezionata.

6.2.3. Indexed collections


All collection mappings, except those with set and bag semantics, need an index column in the collection table. An index column is a column that maps to an array index, or List index, or Map key. The index of a Map may be of any basic type, mapped with <map-key>. It can be an entity reference mapped with <map-key-many-to-many>, or it can be a composite type mapped with <composite-map-key>. The index of an array or list is always of type integer and is mapped using the <list-index> element. The mapped column contains sequential integers that are numbered from zero by default.
<list-index 
        column="column_name"                 
        base="0|1|..."                       
/>
Copy to Clipboard Toggle word wrap

1

column_name (required): the name of the column holding the collection index values.

2

base (optional - defaults to 0): the value of the index column that corresponds to the first element of the list or array.
<map-key 
        column="column_name"                 
        formula="any SQL expression"         
        type="type_name"                     
        node="@attribute-name"
        length="N"/>
Copy to Clipboard Toggle word wrap

1

column (optional): the name of the column holding the collection index values.

2

formula (optional): a SQL formula used to evaluate the key of the map.

3

type (required): the type of the map keys.
<map-key-many-to-many
        column="column_name"                 
        formula="any SQL expression"         
        class="ClassName"                    
/>
Copy to Clipboard Toggle word wrap

1

column (optional): the name of the foreign key column for the collection index values.

2

formula (optional): a SQ formula used to evaluate the foreign key of the map key.

3

class (required): the entity class used as the map key.
If your table does not have an index column, and you still wish to use List as the property type, you can map the property as a Hibernate <bag>. A bag does not retain its order when it is persisted to the database, but it can be optionally sorted or ordered when it is retrieved from the database.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat