我正在尝试在我的事务类(Spring 注释)中获取 SQL 查询的结果:
String query = "SELECT DAT, DROP_RADIO FROM My_TABLE";
SQLQuery q = getCurrentSession().createSQLQuery(query);
q.setResultTransformer(Transformers.aliasToBean(CallDrop.class));
List result = q.list();
和 CallDrop:
public class CallDrop implements java.io.Serializable {
private int id;
private Date dat;
private BigDecimal onRadio;
public BigDecimal getOnRadio() {
return onRadio;
}
public void setOnRadio(BigDecimal onRadio) {
this.onRadio = onRadio;
}
public Date getDat() {
return dat;
}
public void setDat(Date dat) {
this.dat = dat;
}
}
.hbm.xml 是:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.company.beans.CallDrop" table="My_TABLE">
<id name="id" type="int" />
<property name="dat" type="date">
<column name="DAT" length="10" />
</property>
<property name="onRadio" type="big_decimal">
<column name="DROP_RADIO" precision="22" scale="0" />
</property>
</class>
</hibernate-mapping>
我确定我已在会话工厂中将 hbm.xml 添加到 applicationContext 文件中:
<bean id="sessionFactoryETL" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSourceETL"/></property>
<property name="mappingResources">
<list>
<value>com/company/beans/CallDrop.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
所以,没有类型,但它不起作用。有没有人知道问题出在哪里?谢谢