Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5, 3.1b
I am getting tuples with Criteria API. I have two different classes mapped to the same table. They are not inherited from each other. Criteria was created to request one of them. I was very precise on what type of object I want.
Simplified mappings and code:
Map1:
Code:
<class name="Account" table="account">
<id name="accountId" column="ACCOUNT_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="balance" column="BALANCE" />
</class>
Map2:
Code:
<class name="SearchAccount" table="account">
<id name="accountId" column="ACCOUNT_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="balance" column="BALANCE" />
<one-to-one name="account" class="AjDataAccount" />
<set name="customers" lazy="true" order-by="ACCOUNT_ID">
<key column="ACCOUNT_ID" />
<one-to-many class="customer" />
</set>
</class>
I am trying to find account by ID and have built Criteria object for that:
Code:
search = session.createCriteria(SearchAccount.class).add(Expression.eq("accountId", accountId));
Collection accounts = search.list();
Collection accounts will contain one object and it will be Object[] with two elements Object[0] is Account object and Object[1] will be SearchAccount. Why I have array if I have requested specific type(class) of instance? Is it a bug?
This code was working in H2 and does not work in H3. I have tried that in H3.0.5 and H3.1b. Same result.
I much appreciate if somebody can point me on docs part related to that and how can I get homogeneous set of objects
Thank you