[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1952) HQL query that uses implicit polymorphism returns (# concrete classes x n) rows, not n rows, when setMaxResults(n) is used
Steve Ebersole (JIRA)
noreply at atlassian.com
Wed Jan 7 09:40:38 EST 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32065#action_32065 ]
Steve Ebersole commented on HHH-1952:
-------------------------------------
And what would you like to see? Since Hibernate fires off the "concrete queries" one-by-one, we cannot rely on simply passing setMaxResults through to the JDBC driver here.
The only solutions I see are:
1) Disallow setMaxResults in combo with implicit polymorphism queries;
2) Apply the setMaxResults in memory
> HQL query that uses implicit polymorphism returns (# concrete classes x n) rows, not n rows, when setMaxResults(n) is used
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1952
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1952
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Environment: Hibernate: 3.1.3
> Reporter: David Donn
>
> If I have m mapped entities that implement the same interface and execute a polymorphic query with setMaxResults(n) I get n x m rows instead of n rows in my result.
> Query:
> session.createQuery("from Animal").setMaxResults(1)
> Hibernate mapping:
> <class
> name="Lion"
> table="lion" lazy="false">
>
> <id name="id">
> <generator class="sequence">
> <param name="sequence">animal_seq</param>
> </generator>
> </id>
>
> </class>
>
> <class
> name="Tiger"
> table="tiger" lazy="false">
>
> <id name="id">
> <generator class="sequence">
> <param name="sequence">animal_seq</param>
> </generator>
> </id>
>
> </class>
> Class definitions:
> public interface Animal {
> }
> public class Lion implements Animal {
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
>
> }
> public class Tiger implements Animal {
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
>
> }
> SQL:
> create sequence animal_seq start with 1
> /
> create table lion (id number(12) primary key)
> /
> create table tiger (id number(12) primary key)
> /
> insert into lion values (animal_seq.nextval)
> /
> insert into tiger values (animal_seq.nextval)
> /
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list