spkhillar / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
0 stars 0 forks source link

Fetch mode FETCH_LIST and FETCH_ARRAY return unexpected result when only one fetch specified #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Search.
2. Add exactly one fetch.
3. Set fetchMode to FETCH_LIST or FETCH_ARRAY.
4. Run the Search in any Generic or General DAO.

EXPECTED RESULT:
List of Lists with one element each or list of Arrays with one element each.

ACTUAL RESULT:
Both fetch modes return just a List of Objects. Each object is what should
be the single element in the List or Array.

This is the default behavior of Hibernate. We need to find a way to
override it. And perhaps we should have a new fetch mode FETCH_SINGLE.

The reason this behavior is undesirable for us is that searches may be
dynamically built by application users in a custom search or something and
we don't want to have to write special code for the exception where they
only select one column to display.

Original issue reported on code.google.com by dwolvert on 6 Aug 2008 at 1:55

GoogleCodeExporter commented 9 years ago
Turns out the problem was only with fetch mode FETCH_ARRAY. We had been using 
the
default ResultTransformer for this which has the behavior where if there is one 
field
in the result it uses that field by itself but if there are more it puts them 
in an
array.

We implemented our own result transformer to use for FETCH_ARRAY. It always 
returns
an array.

Original comment by dwolvert on 6 Aug 2008 at 2:14