I am trying to use GWTs RequestFactory to (at the moment) do something very simple and return a list of objects each containing some data and another object. I don't seem to be able to get my other object - instead I always get null.
My code looks something like this...
I have some UserMessage objects which each include a Message object.
UserMessage
@Entity
public class UserMessage implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Version
private Integer version = 0;
@ManyToOne
@JoinColumn(name = "messageId")
private Message message;
private String user;
private int priority;
private boolean read;
private Date expiry;
private boolean sent;
... getter/setters etc
Message
@Entity(name = "UUMessage")
public class Message implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Version
private Integer version = 0;
private String title;
private String mimeType;
private String message;
private Date received;
private String fromUser;
public Message() {
}
... getter/setters etc
each with their own proxy classes
UserMessageProxy
@ProxyFor(value = UserMessage.class, locator = UserMessageLocator.class)
public interface UserMessageProxy extends EntityProxy {
Long getId();
void setId(Long id);
MessageProxy getMessage();
void setMessage(MessageProxy message);
String getUser();
}
MessageProxy
@ProxyFor(value = Message.class, locator = MessageLocator.class)
public interface MessageProxy extends EntityProxy {
Long getId();
void setId(Long id);
String getTitle();
void setTitle(String title);
}
I have a factory and a context
@Service(value = CentralNotificationService.class, locator = CentralNotificationServiceLocator.class)
public interface CnsRequestContext extends RequestContext {
Request<List<UserMessageProxy>> getMessagesForUser(String user, int start, int length);
}
When I call getMessagesForUser(...) on the client my server side service code gets called, the entries in the database are retrieved and I get a list of UserMessageProxy returned to the client. Unfortunately calling getMessage() on any of these returns null and I can't work out why.
I am not getting any errors or warnings. On the server side I can "see" that the UserMessage does contain the Message objects when the RequestFactory code calls into my service classes.
Why are my objects null? Are there any conditions I am not satisfying?
GWT 2.4 BTW (but also had problems with 2.3)