Hi all,
I use resquestfactory with Locator and ServiceLocator and am trying to 
persist an entity that has a one to many, but the layer server children are 
not sent. When I do find, the children leave the server to the client layer 
without problems using .wth("child"). Anyone know how to persist in a 
single request?

Follow the entity used:

-- Parent --
public class Usuario implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="usuario_seq") 
@Column(name = "ID", nullable = false)
private Long id;

@Column(name="\"ADMIN\"", length = 1)
private boolean admin = false;

@Column(name = "EMAIL", length = 60)
private String email;

@Column(name = "SENHA", length = 60)
private String senha;

@Column(name="SESSION_ID")
private String sessionId;

//@Version
@Column(name="\"VERSION\"")
private Integer version = 0;

//bi-directional many-to-one association to UsuarioIe
@OneToMany(targetEntity=UsuarioIe.class, cascade=CascadeType.ALL, 
mappedBy="usuario", fetch = FetchType.EAGER)
private List<UsuarioIe> usuarioIes;

@PrePersist
    @PreUpdate
    protected void increment() {
version = version + 1;
    }

-- Child --
public class UsuarioIe implements Serializable {
private static final long serialVersionUID = 1L;

@EmbeddedId
private UsuarioIePK id;

//@Version
@Column(name="\"VERSION\"")
private Integer version = 0;

//bi-directional many-to-one association to Usuario
    @ManyToOne //(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "USUARIO_ID", nullable = false, insertable = false, 
updatable = false) 
    @PrimaryKeyJoinColumn(name="USUARIO_ID", referencedColumnName="ID")
private Usuario usuario;
    
    @PrePersist
    @PreUpdate
    protected void increment() {
version = version + 1;
    }

-- That way I'm doing the persistence --

                RequestContext context = editorDriver.flush();
 this.cachedObject = cachedRequestContext.edit(cachedObject); //here comes 
the object without the children
 List<UsuarioIeProxy> teste = new ArrayList<UsuarioIeProxy>(); //'m riding 
the children to manually test
 for (int i=0; i < ies.getItemCount(); i++) {
UsuarioRequest usuarioRequest = getRequestFactory().usuarioRequest();
UsuarioIeIdProxy id = usuarioRequest.create(UsuarioIeIdProxy.class);
UsuarioIeProxy ie = usuarioRequest.create(UsuarioIeProxy.class);
 id.setIes(ies.getItemText(i));
id.setUsuarioId(cachedObject.getId());
 ie.setId(id);
teste.add(ie); 
}
 cachedObject.setUsuarioIes(teste); 
 cachedRequestContext.persistir(cachedObject).to(new Receiver<Void>() { //
@Override
public void onSuccess(Void arg0) {
performLeave();
AppUtils.eventBus.fireEvent(new UsuarioEvent(null, EditorMode.LEAVE)); 
//TODO - fazer o refresh por linha ou tudo?
}
});
 context.fire();

Thank you.

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

Reply via email to