我有一个包含3个数据的表(节点) - id(pk) - 题 - 结果
和2个外键(多对一) - LEFT_ID - RIGHT_ID
这里是我的hbm
<?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.beans.Nodes" table="node">
<id name="id" type="int" access="field">
<column name="id" />
<generator class="assigned" />
</id>
<property name="question" type="java.lang.String">
<column name="question" />
</property>
<property name="result" type="java.lang.String">
<column name="result" />
</property>
<many-to-one column="LEFT_ID" name="left" class="com.beans.Nodes" insert="false" update="false"></many-to-one>
<many-to-one column="RIGHT_ID" name="right" class="com.beans.Nodes" insert="false" update="false"></many-to-one>
</class>
</hibernate-mapping>
和我的带有getter / setter的bean在LEFT / RIGHT_ID
@Entity
@Table (name = "node")
public class Nodes
{
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column (name = "question")
private String question;
@Column ( name = "result")
private String result;
private Nodes LEFT_ID;
private Nodes RIGHT_ID;
public Nodes getLeftNodes()
{
return LEFT_ID;
}
public void setLeftNodes(Nodes LEFT_ID)
{
this.LEFT_ID=LEFT_ID;
}
public Nodes getRightNodes()
{
return RIGHT_ID;
}
public void setRifhtNodes(Nodes right)
{
this.RIGHT_ID=right;
}
}
但是当我部署我的项目时,我有这个错误
**Query: ReadAllQuery(referenceClass=Nodes sql="SELECT id, question, result, LEFT_ID_id, RIGHT_ID_id FROM node")**
当hibernate是select时,他会更改列的名称。 LEFT_ID变为LEFT_ID_id,并且不可避免地找不到任何东西!
为什么hibernate会更改LEFT_ID列的名称?
感谢