Question : Hibernate Mapping - Stored Proc result from multiple tables

Hibernate 3.0 & MS SQL 2005

I have a stored procedure that gives values from multiple tables. This procdure returns these values in a reslut set. The result set return does not map to a specific table in the db. can i map this result set to an entity in the mapping file? If im not mapping to a table how can I leave out the class element, id element and property elements? is this possible?


"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



>

>

>

>

>









EXEC mrgviewSP :para1, :para2, :para3, :para4, :para5, :para6, :para7, :para8, :para9, :para10, :para11 ) }




--------------Java Code ---------------
List list = null;
try {

Session session = HibernateUtils.currentSession();
Query query = session.getNamedQuery("mrgviewSP");
query.setParameter("para1", obj1 );
query.setParameter("para2", obj2 );
query.setParameter("para3",obj3 );
query.setParameter("para4", obj4 );
query.setParameter("para5",obj5 );
query.setParameter("para6",obj6 );
query.setParameter("para7",obj7 );
query.setParameter("para8",obj8);
query.setParameter("para9",obj9 );
query.setParameter("para10",obj10);
query.setParameter("para11", obj11 );

list = query.list();

HibernateUtils.closeSession();


----------------------POJO----------------
public class ForecastFilter implements java.io.Serializable{

private Short managerId;
private Short price;
private BigDecimal forecast;
private BigDecimal pending;
private BigDecimal booked;

public ForecastFilter(Short managerId, Short price, BigDecimal forecast,
BigDecimal pending, BigDecimal booked) {
super();
this.managerId = managerId;
this.price = price;
this.forecast = forecast;
this.pending = pending;
this.booked = booked;
}

public Short getManagerId() {
return managerId;
}
public void setManagerId(Short managerId) {
this.managerId = managerId;
}
public Short getPrice() {
return price;
}
public void setPrice(Short price) {
this.price = price;
}
public BigDecimal getForecast() {
return forecast;
}
public void setForecast(BigDecimal forecast) {
this.forecast = forecast;
}
public BigDecimal getPending() {
return pending;
}
public void setPending(BigDecimal pending) {
this.pending = pending;
}
public BigDecimal getBooked() {
return booked;
}
public void setBooked(BigDecimal booked) {
this.booked = booked;
}
}

Errors :-

SEVERE: Error parsing XML: XML InputStream(17) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".


Can any one please help me in finding a solution .


Thanks.

Answer : Hibernate Mapping - Stored Proc result from multiple tables

You don't need the element, only the element. The element is for mapping a table in the database to a class. The element with its child element provides the mapping from ResultSet columns to class properties. Remove the element and you should be fine.

Regards,
Jim Cakalic
Random Solutions  
 
programming4us programming4us