Thursday, July 25, 2013

EntityProxy getId is always null for Entity with Composite Key

My Entity uses a @EmbeddedId for its id. I can see that the getId on the entity in the server is returning an instance of the pk class, but it ends up being null in the corresponding entity proxy instance on the client.
 
 
 
request.findAllAccounts()
      .fire(new Receiver<List<AccountProxy>>() {
    @Override
    public void onSuccess(List<AccountProxy> response) {
     for (AccountProxy account: response) {
      Assert.notNull(account.getId());
     }
    }
  });
 
 
public class Account {
    
    @EmbeddedId
    private AccountPk id;
 
    public AccountPk getId() {
      return this.id;
    }
 
   public void setId(AccountPk id) {
     this.id = id;
   }
 
}
 
 
@Embeddable
public class AccountPk implements Serializable {
 
 private static final long serialVersionUID = 1434674L;
 @Column(name="member")
 private Long memberId;
 
 @Column(name="account_type")
 private String accountTypeId;
 
 @Column(name="group_type")
 private String groupTypeId;
 
 @Column(name="cert_ln_number")
 private String certLnNumber;
 
 public AccountPk() {}
 
 public AccountPk(String accountTypeId, String groupTypeId, String certLnNumber, Long memberId) {
  this.accountTypeId = accountTypeId;
  this.groupTypeId = groupTypeId;
  this.certLnNumber = certLnNumber;
  this.memberId = memberId;
 }
 
 
@ProxyForName(value = "com.sharetec.mobile.server.domain.Account", locator = "com.sharetec.mobile.server.locator.AccountLocator")
public interface AccountProxy extends EntityProxy {
 abstract AccountPkProxy getId();
    abstract Integer getVersion();
    abstract Date getLastActivityDate();
    abstract void setLastActivityDate(Date lastActivityDate);
    abstract AccountTypeProxy getAccountType();
    abstract void setAccountType(AccountTypeProxy accountType);
    abstract CreditUnionMemberProxy getMember();
    abstract void setMember(CreditUnionMemberProxy member);
    abstract String getDescription();
    abstract void setDescription(String description);
}
 
@Component
public class AccountLocator extends Locator<Account, AccountPk> {
 
    public Account create(Class<? extends com.sharetec.mobile.server.domain.Account> clazz) {
        return new Account();
    }
    public Account find(Class<? extends com.sharetec.mobile.server.domain.Account> clazz, AccountPk id) {
     return Account.findAccount(id);
    }
    public Class<com.sharetec.mobile.server.domain.Account> getDomainType() {
        return Account.class;
    }
    public AccountPk getId(Account account) {
     return account.getId();
    }
    public Class<AccountPk> getIdType() {
        return AccountPk.class;
    }
    public Object getVersion(Account account) {
        return account.getVersion();
    }
}
 
@ProxyFor(AccountPk.class)
public interface AccountPkProxy extends ValueProxy {
 String getCertLnNumber();
 String getAccountTypeId();
 String getGroupTypeId();
 Long getMemberId();
 
 void setCertLnNumber(String certLnNumber);
 void setAccountTypeId(String accountTypeId);
 void setGroupTypeId(String groupTypeId);
 void setMemberId(Long memberId);
}
 
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment