Closed GoogleCodeExporter closed 9 years ago
首先, 通过这个问题发现: EntityField.setValue
函数有逻辑错误
try {
if (null != value) {
if (field.getType() != value)
value = Castors.me().castTo(value,
field.getType());
}
...
条件 field.getType() 与 value
是永远不等的,所有这个判断没有意义,在 r916
中,我做了修改,将等式
改为 if(field.getType() !=value.getClass())
Original comment by zozoh...@gmail.com
on 10 Mar 2010 at 4:09
通过异常堆栈,看起来是在做转换的时候*没有找到转换器*,
这个似乎不太可能,我测试了:
{{{
int num = Castors.me().castTo("23", int.class);
System.out.println(num);
}}}
看起来输出正常
希望能贴出 Jricprecordip 全部的代码,即使是一个简单的
VO,这样我在本地模拟一下,看看能不能重现这个
问题
Original comment by zozoh...@gmail.com
on 10 Mar 2010 at 4:20
[deleted comment]
Jricprecordip :
@Table("jricprecordip")
public class Jricprecordip implements Serializable {
/**
* This attribute maps to the column id in the jricprecordip table.
*/
@Id
@Column
protected int id;
/**
* This attribute maps to the column jricprecordid in the jricprecordip
* table.
*/
@Column
protected int jricprecordid;
/**
* This attribute maps to the column isprecordid in the jricprecordip table.
*/
@Column
protected int isprecordid;
/**
* This attribute maps to the column ipid in the jricprecordip table.
*/
@Column
protected int ipid;
/**
* This attribute maps to the column startip in the jricprecordip table.
*/
@Column
protected String startip;
/**
* This attribute maps to the column startiplong in the jricprecordip table.
*/
@Column
protected long startiplong;
/**
* This attribute maps to the column endip in the jricprecordip table.
*/
@Column
protected String endip;
/**
* This attribute maps to the column endiplong in the jricprecordip table.
*/
@Column
protected long endiplong;
/**
* Method 'Jricprecordip'
*
*/
public Jricprecordip() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
/**
* Method 'getJricprecordid'
*
* @return int
*/
public int getJricprecordid() {
return jricprecordid;
}
/**
* Method 'setJricprecordid'
*
* @param jricprecordid
*/
public void setJricprecordid(int jricprecordid) {
this.jricprecordid = jricprecordid;
}
/**
* Method 'getIsprecordid'
*
* @return int
*/
public int getIsprecordid() {
return isprecordid;
}
/**
* Method 'setIsprecordid'
*
* @param isprecordid
*/
public void setIsprecordid(int isprecordid) {
this.isprecordid = isprecordid;
}
/**
* Method 'getStartip'
*
* @return String
*/
public String getStartip() {
return startip;
}
/**
* Method 'setStartip'
*
* @param startip
*/
public void setStartip(String startip) {
this.startip = startip;
}
/**
* Method 'getStartiplong'
*
* @return long
*/
public long getStartiplong() {
return startiplong;
}
/**
* Method 'setStartiplong'
*
* @param startiplong
*/
public void setStartiplong(long startiplong) {
this.startiplong = startiplong;
}
/**
* Method 'getEndip'
*
* @return String
*/
public String getEndip() {
return endip;
}
/**
* Method 'setEndip'
*
* @param endip
*/
public void setEndip(String endip) {
this.endip = endip;
}
/**
* Method 'getEndiplong'
*
* @return long
*/
public long getEndiplong() {
return endiplong;
}
/**
* Method 'setEndiplong'
*
* @param endiplong
*/
public void setEndiplong(long endiplong) {
this.endiplong = endiplong;
}
/**
* Method 'equals'
*
* @param _other
* @return boolean
*/
public boolean equals(Object _other) {
if (_other == null) {
return false;
}
if (_other == this) {
return true;
}
if (!(_other instanceof Jricprecordip)) {
return false;
}
final Jricprecordip _cast = (Jricprecordip) _other;
if (id != _cast.id) {
return false;
}
if (jricprecordid != _cast.jricprecordid) {
return false;
}
if (isprecordid != _cast.isprecordid) {
return false;
}
if (ipid != _cast.ipid) {
return false;
}
if (startip == null ? _cast.startip != startip : !startip.equals
(_cast.startip)) {
return false;
}
if (startiplong != _cast.startiplong) {
return false;
}
if (endip == null ? _cast.endip != endip : !endip.equals
(_cast.endip)) {
return false;
}
if (endiplong != _cast.endiplong) {
return false;
}
return true;
}
/**
* Method 'hashCode'
*
* @return int
*/
public int hashCode() {
int _hashCode = 0;
_hashCode = 29 * _hashCode + id;
_hashCode = 29 * _hashCode + jricprecordid;
_hashCode = 29 * _hashCode + isprecordid;
_hashCode = 29 * _hashCode + ipid;
if (startip != null) {
_hashCode = 29 * _hashCode + startip.hashCode();
}
_hashCode = 29 * _hashCode + (int) (startiplong ^ (startiplong >>>
32));
if (endip != null) {
_hashCode = 29 * _hashCode + endip.hashCode();
}
_hashCode = 29 * _hashCode + (int) (endiplong ^ (endiplong >>> 32));
return _hashCode;
}
/**
* Method 'toString'
*
* @return String
*/
public String toString() {
StringBuffer ret = new StringBuffer();
ret.append("com.mycompany.myapp.dto.Jricprecordip: ");
ret.append("id=" + id);
ret.append(", jricprecordid=" + jricprecordid);
ret.append(", isprecordid=" + isprecordid);
ret.append(", ipid=" + ipid);
ret.append(", startip=" + startip);
ret.append(", startiplong=" + startiplong);
ret.append(", endip=" + endip);
ret.append(", endiplong=" + endiplong);
return ret.toString();
}
public int getIpid() {
return ipid;
}
public void setIpid(int ipid) {
this.ipid = ipid;
}
public void setId(Integer id) {
this.id = id;
}
对应的表结构:
Column name Type Nulls
id serial no
jricprecordid integer no
isprecordid integer no
ipid integer no
startip char(20) no
startiplong decimal(10,0) no
endip char(20) no
endiplong decimal(10,0) no
Original comment by Toni.xu...@gmail.com
on 10 Mar 2010 at 5:05
数据库:Informix Dynamic Server 2000 Version 9.21.UC2
Original comment by Toni.xu...@gmail.com
on 10 Mar 2010 at 5:08
我反对 r916修改:
if (field.getType() != value.getClass())
起码用 equal啊, 再说, 这个应该使用 isAssginFrom
Original comment by wendal1985@gmail.com
on 10 Mar 2010 at 5:18
sorry, 是 Class.isAssignableFrom(Class clz)
Original comment by wendal1985@gmail.com
on 10 Mar 2010 at 5:21
我的修改体现在 r918
Original comment by wendal1985@gmail.com
on 10 Mar 2010 at 5:25
我刚跟同事沟通,发现他的代码那边没有出现这种问题,我��
�我的JAVA工程里面的JAR包跟同事同步成一样的
发现就不存在这个问题了。。 现在问题已解决了
我怀疑JAR间有冲突。。很遗憾 我之前没有记下我的旧的工
程里面 有什么JAR包
Original comment by Toni.xu...@gmail.com
on 10 Mar 2010 at 6:41
如果是这样的话,我怀疑是 Castors
根本没有加载上,为了以后能更清晰的暴露这个问题,每次��
�不到 Castors
是,抛出的 Exception 应该带着 Castors 的 map.size()
Fixed in r919
Append "FAQ"
Original comment by zozoh...@gmail.com
on 10 Mar 2010 at 7:03
Original comment by wendal1985@gmail.com
on 15 Mar 2010 at 5:07
Original comment by wendal1985@gmail.com
on 13 May 2010 at 11:03
Original comment by zozoh...@gmail.com
on 14 May 2010 at 10:39
Original issue reported on code.google.com by
zozoh...@gmail.com
on 10 Mar 2010 at 4:06