views:

64

answers:

1

Hi all,

I've this error when I try to load a list of "Product" in a simple DataGrid :

Didn't receive an acknowledge message
Was expecting mx.messaging.messages.AcknowledgeMessage, but received null

After several tests I'm pretty sure now that it's a mapping issue, and as I'm not used to annotations, maybe it comes from here, here are my classes :

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...
}

Category doesn't matter because there's only an Id and an Name, the association between Product and Category is unidirectional, the real issue is when I try to retrieve my Products from the database, this error happen and as I said, I'm almost certain it comes from a mapping/annotation mistake...

Thanks.

A: 

The problem is that you probably don't reference the class Buy.as anywhere in your Flex application, so the Flex compiler did not include it in the swf, leading to this ArgumentError during deserialization. A quick way of checking this is to add a dummy variable in your mxml : private static var dummy:Buy = null;

You will find a more detailed explanation here.

wdrai
I just added this in my mxml : import tuto.*; private static var a: Buy = new Buy (); private static var b: Client = new Client (); private static var c: Product = new Product (); private static var d: Category = new Category ();But I'm still having the same error... Did I miss something ?
Arnaud
Hum, I guess you have generated the AS3 classes with the Gas3 tool.Can you post the 3 AS3 entities ?
wdrai