String queryString = "from XlrzFJ as t ";
我要查询 XlrzFJ 所有类 可是一个属性 infor_id 已经用于mant-to-one
name="xlrzInfor"
class="cn.hnedu.hnbys.database.XlrzInfor"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="infor_id"
not-null="true"
/>
所以XlrzFJ.hbm.xml就没有
这一列的配置
查出来的XlrzFJ infor_id=null 要如何才能查出来 数据库里infor_id 有值
[quote]所以XlrzFJ.hbm.xml就没有
这一列的配置 [/quote]
可以有这一列的配置的.
你配置没对吧.
下面的代码运行了.是能得到外键值的.
[code="java"]<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
type="java.lang.Long" />
name="xlrzinfor"
class="com.Xlrzinfor"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="infor_id"
not-null="true"
/>
</class>
[/code]
[code="java"]<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
</class>
[/code]
[code="java"]package com;
import java.util.HashSet;
import java.util.Set;
/**
public class Xlrzfj implements java.io.Serializable {
// Fields
private Long id;
private Long inforId;
private Xlrzinfor xlrzinfor;
// Constructors
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getInforId() {
return inforId;
}
public void setInforId(Long inforId) {
this.inforId = inforId;
}
public Xlrzinfor getXlrzinfor() {
return xlrzinfor;
}
public void setXlrzinfor(Xlrzinfor xlrzinfor) {
this.xlrzinfor = xlrzinfor;
}
}[/code]
[code="java"]package com;
/**
public class Xlrzinfor implements java.io.Serializable {
// Fields
private Long id;
private String content;
// Constructors
/** default constructor */
public Xlrzinfor() {
}
/** minimal constructor */
public Xlrzinfor(Long id) {
this.id = id;
}
/** full constructor */
public Xlrzinfor(Long id, String content) {
this.id = id;
this.content = content;
}
// Property accessors
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getContent() {
return this.content;
}
public void setContent(String content) {
this.content = content;
}
}[/code]
[size=x-large][color=red]希望对你有所帮助....[/color][/size]
from XlrzFJ as t 这个XlrzFJ是这个配置对应的实体名称?如果不是当然查不出来值了
from XlrzFJ这样是以对象形式获取的,但是你这个要获取infor_id的值的话,就要获得这个xlrzInfor,然后再获取具体的infor_id的值。或者获得跟这个infor_id相关的信息的。他现在是多对一的一个集合,你查的话,只能是查到跟这个infor_id相对于的多个一的集合。