Friday, September 24, 2010

Setting id for record @DataTransferObject

Hello - is it possible to set the id for a @DataTransferObject instead
of the jpa generated one? I'm using 2.1M3

I've tried creating the id property but this fails because the
property 'id' is already set in the super class Record, and have tried
to add the setter setId() but this fails with
'The type UserRecordImpl must implement the inherited abstract method
UserRecord.setId(Long)'

Here is the DTO:
@DataTransferObject(com.eventismo.server.domain.User.class)
public interface UserRecord extends Record {

// next line causes exception, ambiguous field as declared in
the Record super type
//Property<Long> id = new Property<Long>("id", "User Id",
Long.class);
Property<String> userName = new Property<String>("userName", "User
Name", String.class);
...
String getUserName();

void setUserName(String userName);
// fails
void setId(Long department);


// And here is the calling code
RequestObject<Void> requestObject;
userRecord = (UserRecord)
requestFactory.create(UserRecord.class);
requestObject = requestFactory.userRequest().persist(userRecord);
UserRecord editableUser = requestObject.edit(userRecord);
editableUser.setUserName(name);
editableUser.setDisplayName(first_name);
editableUser.setId(Long.parseLong(id));
// persist user
requestObject.fire(new Receiver<Void>() {
..

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment