SqlServer dialect 2008, error "column was specified multiple times" when using
limit and offset
-----------------------------------------------------------------------------------------------
Key: HHH-6835
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6835
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.8
Environment: 3.6.8 sqlserver 2008, 10.00.1600
Reporter: Nils Dennefors
Priority: Minor
Can't use limit and offset on (jpql) queries when a column is defined two times and
using different cases on entity.
Like in the example below name="FIRM_ID" and name="firm_id"
If I use the same case on column definition the problem disappears.
Perhaps the dialect should do a case-insensitive check on column name?
{{@Entity}}
{{public class Customer {}}
{{(a)ManyToOne(targetEntity=Firm.class)}}
{{@JoinColumn(name="FIRM_ID",referencedColumnName="id",insertable=false,updatable=false)}}
{{Firm firm;}}
{{@Column(name = "firm_id")}}
{{public Long firmId;}}
{{@Id}}
{{@Column(name = "cust_id", nullable = false)}}
{{public Long customerNr;}}
{{}}}
{{@Entity}}
{{public class Firm {}}
{{@Id}}
{{(a)GeneratedValue(strategy=GenerationType.IDENTITY)}}
{{Long id;}}
{{}}}
When executing this:
{{List<Firm> resultList = em.createQuery("select a from Customer
a").setFirstResult(1).setMaxResults(2).getResultList();}}
Hibernate executes sql:
{{WITH query AS (select ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as
__hibernate_row_nr__, customer0_.cust_id as cust1_0_, customer0_.firm_id as firm2_0_,
customer0_.firm_id as firm2_0_ from customer customer0_) SELECT * FROM query WHERE
__hibernate_row_nr__ BETWEEN ? AND ?}}
Which is not valid because firm2_0_ is used two times.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira