CRITICAL
Rule Definition
Hibernate supports this usage; indeed, the details of an array mapping are virtually identical to those of a list. However, we very strongly recommend against the use of arrays, since arrays can't be lazily initialized (there is no way to proxy an array at the virtual machine level).
Lists, maps and sets are the most efficient collection types.
So, using array can affect your application performance when it can contain many items, it looses lazy loading, optimized dirty checking and performance features for persistent collections.
Remediation
Use lists, maps, bags, idbags and sets depending on your case.
Violation Code Sample
<hibernate-mapping >
<class name="A" table ="A">
<id name="id" column="A_ID">
<generator class="increment"/>
</id>
<array name="Bitems" cascade="all" fetch="join"> // VIOLATION
<key column="A_ID"/>
<one-to-many class="B"/>
</array>
</class>
<class name="B" table="B" lazy="true">
<id name="id" column="B_ID">
<generator class="increment"/>
</id>
</class>
</hibernate-mapping
Fixed Code Sample
<hibernate-mapping >
<class name="A" table ="A">
<id name="id">
<generator class="increment"/>
</id>
// FIXED with a list (it could have been set, map, idbag or bag)
<list name="Bitems" cascade="all" fetch="join">
<key column="B_ID"/>
<list-index column="ID"/>
<one-to-many class="B"/>
</array>
</class>
<class name="B" table="B" lazy="true">
<id name="id" column="B_ID">
<generator class="increment"/>
</id>
</class>
</hibernate-mapping>
Reference
Hibernate in Action (ISBN 1932394-15-X) p 214
http://srcrr.com/java/hibernate/3.6.2/reference/org/hibernate/collection/PersistentArrayHolder.html
Related Technologies
JEE
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.