| I can confirm this bug using Wildfly 10.1 with Hibernate 5.0.11 and Microsoft SQL Server 2012. The stored procedure returns 2 result sets. The first SELECT should be mapped to ResultCount, the second SELECT to ResultEntity (see below).
SELECT NEWID() as id, 3 as [count]
SELECT 1 as idd, 'A' as name UNION SELECT 2 as idd, 'B' as name UNION SELECT 3 as idd, 'C' as name
I've used JPA to call the stored procedure
StoredProcedureQuery qry = _em.createStoredProcedureQuery("usp_test", ResultCount.class, ResultEntity.class);
do {
System.out.println(qry.getResultList());
} while(qry.hasMoreResults());
Expected Result (tested with eclipselink 2.6.4):
Current Result (using hibernate 5.0.11):
The entities:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class ResultCount {
private String id;
private long count;
@Id
@Column(name="id")
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
@Column(name="count")
public long getCount() {
return this.count;
}
public void setCount(long count) {
this.count = count;
}
}
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class ResultEntity {
private Integer id;
private String name;
@Id
@Column(name="idd")
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name="name")
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
|