This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
At first glance, this might look like another non-example, but I'm posting it to explain a point.
In my day job, I need to work with arrays of primitive data types, and I needed to find out how Hibernate would handle that. That's why I built this example. At first, it looked like Hibernate handled it just fine, without any annotation at all (you can see that in the example below).
However, after running the example, I investigated what was in the database. It looks like Hibernate is not creating a separate table to hold the values of the array. Instead, Hibernate serializes the array.
This will work fine in some cases, but it could present problems in other cases:
You can't query the database to get just the value of a single array element.
This will not scale to large arrays. The only way Hibernate can access a single element of the array is to reconstruct the entire array.