本人用spring1.2 + Hibernate 3.13
用eclipse自动生成hbm.xml
如:表单Userms
<?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">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="hibernate.dataobject.Userms" table="USERMS" schema="ORACLE">
<composite-id name="id" class="hibernate.dataobject.UsermsId">
<key-property name="recno" type="java.lang.String">
<column name="RECNO" length="20" />
</key-property>
<key-property name="userno" type="java.lang.String">
<column name="USERNO" length="20" />
</key-property>
<key-property name="username" type="java.lang.String">
<column name="USERNAME" length="20" />
</key-property>
<key-property name="userpwd" type="java.lang.String">
<column name="USERPWD" length="30" />
</key-property>
</key-property>
</composite-id>
</class>
</hibernate-mapping>public class Userms implements java.io.Serializable {
// Fields private UsermsId id;
// Constructors /** default constructor */
public Userms() {
id = new UsermsId();
}
// Property accessors public UsermsId getId() {
return this.id;
}
public void setId(UsermsId id) {
this.id = id;
}
}
public class UsermsId implements java.io.Serializable {
// Fields private String recno;
private String userno;
private String username;
private String userpwd;
// Constructors /** default constructor */
public UsermsId() {
}
/** full constructor */
public UsermsId(String recno, String userno, String username, String userpwd) {
this.recno = recno;
this.userno = userno;
this.username = username;
this.userpwd = userpwd; }
// Property accessors public String getRecno() {
return this.recno;
}
public void setRecno(String recno) {
this.recno = recno;
} public String getUserno() {
return this.userno;
}
public void setUserno(String userno) {
this.userno = userno;
} public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
} public String getUserpwd() {
return this.userpwd;
}
public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof UsermsId) ) return false;
UsermsId castOther = ( UsermsId ) other;
return ( (this.getRecno()==castOther.getRecno()) || ( this.getRecno()!=null && castOther.getRecno()!=null && this.getRecno().equals(castOther.getRecno()) ) )
&& ( (this.getUserno()==castOther.getUserno()) || ( this.getUserno()!=null && castOther.getUserno()!=null && this.getUserno().equals(castOther.getUserno()) ) )
&& ( (this.getUsername()==castOther.getUsername()) || ( this.getUsername()!=null && castOther.getUsername()!=null && this.getUsername().equals(castOther.getUsername()) ) )
&& ( (this.getUserpwd()==castOther.getUserpwd()) || ( this.getUserpwd()!=null && castOther.getUserpwd()!=null && this.getUserpwd().equals(castOther.getUserpwd()) ) ));
}
public int hashCode() {
int result = 17;
result = 37 * result + ( getRecno() == null ? 0 : this.getRecno().hashCode() );
result = 37 * result + ( getUserno() == null ? 0 : this.getUserno().hashCode() );
result = 37 * result + ( getUsername() == null ? 0 : this.getUsername().hashCode() );
result = 37 * result + ( getUserpwd() == null ? 0 : this.getUserpwd().hashCode() );
return result;
} }在执行数据提出时,如果recno,userno,username,userpwd中有一个数据为空
DEBUG http-8080-Processor22 org.hibernate.loader.Loader - result set row: 0
必须全部都不为空,才会有
DEBUG http-8080-Processor25 org.hibernate.loader.Loader - result row: EntityKey[hibernate.dataobject.Userms#component[recno,userno,username,userpwd,]{ userpwd=78945612., username=测试, recno=USEM20100425000041, userno=10001}]因表单主键采取的是后台Trigger生成方式,故在eclipse中关于ID Generator选取的是foreign方式,就自动生成了上述的文件.请各位指出,如果修改,可以得到正确结果?
用eclipse自动生成hbm.xml
如:表单Userms
<?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">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="hibernate.dataobject.Userms" table="USERMS" schema="ORACLE">
<composite-id name="id" class="hibernate.dataobject.UsermsId">
<key-property name="recno" type="java.lang.String">
<column name="RECNO" length="20" />
</key-property>
<key-property name="userno" type="java.lang.String">
<column name="USERNO" length="20" />
</key-property>
<key-property name="username" type="java.lang.String">
<column name="USERNAME" length="20" />
</key-property>
<key-property name="userpwd" type="java.lang.String">
<column name="USERPWD" length="30" />
</key-property>
</key-property>
</composite-id>
</class>
</hibernate-mapping>public class Userms implements java.io.Serializable {
// Fields private UsermsId id;
// Constructors /** default constructor */
public Userms() {
id = new UsermsId();
}
// Property accessors public UsermsId getId() {
return this.id;
}
public void setId(UsermsId id) {
this.id = id;
}
}
public class UsermsId implements java.io.Serializable {
// Fields private String recno;
private String userno;
private String username;
private String userpwd;
// Constructors /** default constructor */
public UsermsId() {
}
/** full constructor */
public UsermsId(String recno, String userno, String username, String userpwd) {
this.recno = recno;
this.userno = userno;
this.username = username;
this.userpwd = userpwd; }
// Property accessors public String getRecno() {
return this.recno;
}
public void setRecno(String recno) {
this.recno = recno;
} public String getUserno() {
return this.userno;
}
public void setUserno(String userno) {
this.userno = userno;
} public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
} public String getUserpwd() {
return this.userpwd;
}
public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof UsermsId) ) return false;
UsermsId castOther = ( UsermsId ) other;
return ( (this.getRecno()==castOther.getRecno()) || ( this.getRecno()!=null && castOther.getRecno()!=null && this.getRecno().equals(castOther.getRecno()) ) )
&& ( (this.getUserno()==castOther.getUserno()) || ( this.getUserno()!=null && castOther.getUserno()!=null && this.getUserno().equals(castOther.getUserno()) ) )
&& ( (this.getUsername()==castOther.getUsername()) || ( this.getUsername()!=null && castOther.getUsername()!=null && this.getUsername().equals(castOther.getUsername()) ) )
&& ( (this.getUserpwd()==castOther.getUserpwd()) || ( this.getUserpwd()!=null && castOther.getUserpwd()!=null && this.getUserpwd().equals(castOther.getUserpwd()) ) ));
}
public int hashCode() {
int result = 17;
result = 37 * result + ( getRecno() == null ? 0 : this.getRecno().hashCode() );
result = 37 * result + ( getUserno() == null ? 0 : this.getUserno().hashCode() );
result = 37 * result + ( getUsername() == null ? 0 : this.getUsername().hashCode() );
result = 37 * result + ( getUserpwd() == null ? 0 : this.getUserpwd().hashCode() );
return result;
} }在执行数据提出时,如果recno,userno,username,userpwd中有一个数据为空
DEBUG http-8080-Processor22 org.hibernate.loader.Loader - result set row: 0
必须全部都不为空,才会有
DEBUG http-8080-Processor25 org.hibernate.loader.Loader - result row: EntityKey[hibernate.dataobject.Userms#component[recno,userno,username,userpwd,]{ userpwd=78945612., username=测试, recno=USEM20100425000041, userno=10001}]因表单主键采取的是后台Trigger生成方式,故在eclipse中关于ID Generator选取的是foreign方式,就自动生成了上述的文件.请各位指出,如果修改,可以得到正确结果?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货