当我尝试在简单的DataGrid中加载“Product”列表时出现此错误:
Didn't receive an acknowledge message
Was expecting mx.messaging.messages.AcknowledgeMessage, but received null
经过多次测试后,我很确定这是一个映射问题,因为我不习惯注释,也许它来自这里,这里是我的课程:
Product.java:
@Entity
@Table(name="product")
public class Product implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="product_id")
private long productId;
private String name;
@ManyToOne(optional = false, fetch = FetchType.EAGER)
@JoinColumn(name="category_id")
private Category category;
@OneToMany(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Collection<Buy> clients;
...Getters & Setters...
}
Client.java
@Entity
@Table(name="client")
public class Client implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="client_id")
private long clientId;
private String name;
@OneToMany(mappedBy = "client", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Collection<Buy> products;
public long getClientId() {
return clientId;
}
public void setClientId(long clientId) {
this.clientId = clientId;
}
...Getters & Setters...
}
Buy.java
@Entity
@Table(name="buy")
public class Buy implements Serializable
{
@EmbeddedId
private BuyId buyId;
@ManyToOne
@PrimaryKeyJoinColumn(name="product_id", referencedColumnName="product_id")
private Product product;
@ManyToOne
@PrimaryKeyJoinColumn(name="client_id", referencedColumnName="client_id")
private Client client;
@Temporal(value = TemporalType.DATE)
private Date date;
...Getters & Setters...
}
BuyId.java
public class BuyId implements Serializable
{
private long clientId;
private long productId;
...Getters & Setters...
}
类别并不重要,因为只有Id和Name,Product和Category之间的关联是单向的,真正的问题是当我尝试从数据库中检索我的产品时,这个错误发生了,就像我说的,我几乎可以肯定它来自映射/注释错误......
感谢。
答案 0 :(得分:1)
问题是您可能不会在Flex应用程序的任何位置引用类Buy.as,因此Flex编译器不会将其包含在swf中,从而在反序列化期间导致此ArgumentError。 检查这个的一种快速方法是在mxml中添加一个虚拟变量: private static var dummy:Buy = null;
您会找到更详细的解释here。