(Tangent: What's a "bump posting"?)
Here's the relevant parts of the solution that I used:
The IdAbbrev.java object:
Code:
public class IdAbbrev
{
private Integer id;
private String abbreviation;
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
public String getAbbreviation()
{
return abbreviation;
}
public void setAbbreviation(String abbreviation)
{
this.abbreviation = abbreviation;
}
}
Hibernate mapping file fragment:
Code:
<class name="IdAbbrev" mutable="false" >
<id name="id" >
<generator class="increment"/>
</id>
<property name="abbreviation" />
</class>
<sql-query name="getVehicleIdAbbrevs">
<return class="IdAbbrev"/>
select vehicle_id as id,abbrv as abbreviation from vehicle, vehicle_typ vt where vehicle_typ = ft.vehicle_typ and vt.has_motor = :hasMotor
</sql-query>
Using this in my Spring DAO implementation:
Code:
public List getVehicleIdsAndAbbreviations(Boolean hasMotor)
{
Query q = getSession().getNamedQuery("getVehicleIdAbbrevs");
q.setParameter("hasMotor", hasMotor);
return q.list();
}