<hibernate-mapping>
<class name="com.dangan.dao.pojo.Tcrole" table="TCROLE" schema="DLSYS">
<id name="roleid" type="java.math.BigDecimal">
<column name="ROLEID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="rolename" type="java.lang.String">
<column name="ROLENAME" length="80" />
</property>
<property name="roledescription" type="java.lang.String">
<column name="ROLEDESCRIPTION" />
</property>
<property name="unitid" type="java.math.BigDecimal">
<column name="UNITID" precision="22" scale="0" />
</property>
<property name="displayorder" type="java.math.BigDecimal">
<column name="DISPLAYORDER" precision="22" scale="0" />
</property>
<property name="roleproperty" type="java.math.BigDecimal">
<column name="ROLEPROPERTY" precision="22" scale="0" not-null="true" />
</property>
</class>
</hibernate-mapping>
public class Tcrole implements java.io.Serializable {
// Fields
private BigDecimal roleid;
private String rolename;
private String roledescription;
private BigDecimal unitid;
private BigDecimal displayorder;
private BigDecimal roleproperty;
// Constructors
/** default constructor */
public Tcrole() {
}
/** minimal constructor */
public Tcrole(BigDecimal roleid, BigDecimal roleproperty) {
this.roleid = roleid;
this.roleproperty = roleproperty;
}
/** full constructor */
public Tcrole(BigDecimal roleid, String rolename, String roledescription,
BigDecimal unitid, BigDecimal displayorder, BigDecimal roleproperty) {
this.roleid = roleid;
this.rolename = rolename;
this.roledescription = roledescription;
this.unitid = unitid;
this.displayorder = displayorder;
this.roleproperty = roleproperty;
}
// Property accessors
public BigDecimal getRoleid() {
return this.roleid;
}
public void setRoleid(BigDecimal roleid) {
this.roleid = roleid;
}
public String getRolename() {
return this.rolename;
}
public void setRolename(String rolename) {
this.rolename = rolename;
}
public String getRoledescription() {
return this.roledescription;
}
public void setRoledescription(String roledescription) {
this.roledescription = roledescription;
}
public BigDecimal getUnitid() {
return this.unitid;
}
public void setUnitid(BigDecimal unitid) {
this.unitid = unitid;
}
public BigDecimal getDisplayorder() {
return this.displayorder;
}
public void setDisplayorder(BigDecimal displayorder) {
this.displayorder = displayorder;
}
public BigDecimal getRoleproperty() {
return this.roleproperty;
}
public void setRoleproperty(BigDecimal roleproperty) {
this.roleproperty = roleproperty;
}
}
application.xml的配置
<bean id="sessionFactoryUser"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceUser"></property>
<property name="mappingResources">
<list>
<value>com/dangan/dao/pojo/Tchuman.hbm.xml</value>
<value>com/dangan/dao/pojo/Tcunit.hbm.xml</value>
<value>com/dangan/dao/pojo/Tcrole.hbm.xml</value>
<value>com/dangan/dao/pojo/Tchumanrole.hbm.xml</value>
<value>com/dangan/dao/pojo/Dangan.hbm.xml</value>
<value>com/dangan/dao/pojo/Tzrec1578.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">50</prop>
<prop key="hibernate.jdbc.fetch_size">100</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
</props>
</property>
</bean>
hql语句是这样的
/**
* 返会某个部门所有人员的档案权限查询情况
* @return
*/
public String humanRoles(){
humans=tchumanService.find("select human from Tchuman human where human.tcunitId=?", unitId);
roles=tcroleService.find("select r from Tcrole r where r.unitid=?", 1376);
return Action.SUCCESS;
}
上面的humans的查询没有问题,tcrole的就有问题了,application里面业配置了,pojo类是hibernate反向工程生成的,Tcrole.hbm.xml和Tcrole的属性也是对应的,没拼错,不知道那里问题了。
如果是4的话推荐用jpa
为嘛没人来答啊啊啊啊