我正在使用Flex 3.5,BlazeDS 3.2.0.3978和EJB3作为后端 . 有两个RPC对问题很重要 . 第一个调用将获得ThirdParty对象的列表,这很好 . 第二个调用发生在用户单击ThirdParty时,将检索此对象(延迟集合)的详细信息 . 返回单个对象,其中大多数字段已序列化 . 我说的最多,因为出于某种原因,4个布尔字段没有被序列化,默认情况下由flex设置为false .
这是java bean:
package com.rekencentra.svc.cfos.model.security;
@Entity
@Table(
name = "AUTH_THP",
uniqueConstraints = {
@UniqueConstraint(columnNames={"THP_ID", "OTH_THP_ID"})
}
)
@NamedQueries({
@NamedQuery(
name="allAuthorizationsForThp",
query="SELECT DISTINCT c FROM AuthorisationThirdParty c " +
" LEFT JOIN FETCH c.otherThirdParty thp" +
" LEFT JOIN FETCH thp.goodRegulation" +
" WHERE c.thirdParty.id = :id" +
" AND c.authValidFrom = sysdate()"
)}
)
@SequenceGenerator(name="seqSerialId", sequenceName="SEQ_AUTH_THP")
public class AuthorisationThirdParty extends BusinessObject {
private static final long serialVersionUID = -4187381385945255374L;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.REFRESH})
@JoinColumn(name="THP_ID", nullable=false)
private ThirdParty thirdParty;
@ManyToOne(fetch=FetchType.EAGER, cascade = {CascadeType.REFRESH})
@JoinColumn(name="OTH_THP_ID", nullable=false)
private ThirdParty otherThirdParty;
@Column(name="ICT_F", nullable=false)
private Boolean authForTemplates;
@Column(name="ICN_F", nullable=false)
private Boolean authForConsignments;
@Column(name="SC_F", nullable=false)
private Boolean authForSalesContracts;
@Column(name="PC_F", nullable=false)
private Boolean authForPurchaseContracts;
@Column(name="FROM_DATE", nullable=true)
@Temporal(TemporalType.DATE)
private Date authValidFrom;
@Column(name="UNTIL_DATE", nullable=true)
@Temporal(TemporalType.DATE)
private Date authValidTo;
public ThirdParty getThirdParty() {
return thirdParty;
}
public void setThirdParty(ThirdParty thirdParty) {
this.thirdParty = thirdParty;
}
public ThirdParty getOtherThirdParty() {
return otherThirdParty;
}
public void setOtherThirdParty(ThirdParty otherThirdParty) {
this.otherThirdParty = otherThirdParty;
}
public Date getAuthValidFrom() {
return authValidFrom;
}
public void setAuthValidFrom(Date authValidFrom) {
this.authValidFrom = authValidFrom;
}
public Date getAuthValidTo() {
return authValidTo;
}
public void setAuthValidTo(Date authValidTo) {
this.authValidTo = authValidTo;
}
public void setAuthForTemplates(Boolean authForTemplates) {
this.authForTemplates = authForTemplates;
}
public boolean isAuthForTemplates() {
return authForTemplates;
}
public void setAuthForConsignments(Boolean authForConsignments) {
this.authForConsignments = authForConsignments;
}
public boolean isAuthForConsignments() {
return authForConsignments;
}
public void setAuthForSalesContracts(Boolean authForSalesContracts) {
this.authForSalesContracts = authForSalesContracts;
}
public boolean isAuthForSalesContracts() {
return authForSalesContracts;
}
public void setAuthForPurchaseContracts(Boolean authForPurchaseContracts) {
this.authForPurchaseContracts = authForPurchaseContracts;
}
public boolean isAuthForPurchaseContracts() {
return authForPurchaseContracts;
}
}
和相应的flex类:
package com.rekencentra.ifb.cfos.model.dto.security
{
[Bindable]
[ExcludeClass]
internal class AuthorisationThirdPartyBase extends BusinessObject
{
public var thirdParty:ThirdParty;
public var otherThirdParty:ThirdParty;
public var authForTemplates:Boolean; // missing ser.
public var authForConsignments:Boolean; //missing ser.
public var authForSalesContracts:Boolean; //missing ser.
public var authForPurchaseContracts:Boolean; //missing ser.
public var authValidFrom:Date;
public var authValidTo:Date;
}
}
package com.rekencentra.ifb.cfos.model.dto.security
{
[Bindable]
[RemoteClass(alias="com.rekencentra.svc.cfos.model.security.AuthorisationThirdParty")]
public class AuthorisationThirdParty extends AuthorisationThirdPartyBase
{
}
}
注意:为方便起见,我省略了import语句 .
我已经将blazeDS日志设置为调试和所有字段,但这些布尔值显示在输出中 . 接下来,我尝试逐步完成序列化过程,但很容易迷失在那里 .
3 回答
您的java类没有缺少字段的getter . 如果要传递字段,则序列化程序需要获取字段 .
也许'是' - 方法不被认可?你应该尝试在'get'-Methods中重命名它们 .
你能尝试将setter更改为原始布尔值吗?类型不一致:getter中的primitive和setter中的包装器 .
即使私有var设置为包装器布尔值,它也应该同时将getter和setter设置为原始布尔值 .
但是对于其他类型的情况,您应该使用get和set配对 - 包括字符串 .