1

this is my first app. I have problem between gwt (rpc) and my db (MySQL). JUnit tests run great. Here is my code: https://github.com/sutakjakub/game

client package:

UserService.Util.getInstance().addUser("kuba","tajne",
new AsyncCallback<Long>() {

@Override
public void onFailure(Throwable arg0) {
Window.alert("get se nezdaril" + arg0);

}

@Override
public void onSuccess(Long id) {
if(id == null){
Window.alert("null");
}else{
Window.alert("zapsano do db; id=" + id);
}

}

});

This method must return id of new user but it return null (in method onSuccess(Long id)).

I dont have some error logs. I tried almost everything. Thank you very much for some idea or solution.

Wooble
  • 87,717
  • 12
  • 108
  • 131

1 Answers1

0

An updated entity isn't returned from your saveOrUpdate method (GenericHibernateJpaDao):

@Override
public <ENTITY extends AbstractBussinessObject> ENTITY saveOrUpdate(ENTITY o) {
  if(o.getId() == null){
    getEntityManager().persist(o);
  }else{
    getEntityManager().merge(o);
  }
return o;
}

Should become:

return getEntityManager().merge(o);

If you want to use persist(), then you should probably read this as well.

Community
  • 1
  • 1
Szymon Jednac
  • 2,969
  • 1
  • 29
  • 43
  • Unfortunately, this not solved my problem :-/. Can i ask you ... why my tests are functional but call in gwt not? I dont understand. Thank you very much :) – user1805440 Mar 07 '13 at 19:08
  • 1) Is the associated ID visible in your LOG (in UserServiceImpl)? 2) Your tests call us.addUser(null, "secrete") (for example), which will return null, since you check both arguments for != null, before creating an account, and the return value is initially set to null. I didn't run them tough, since you execute those on an existing MySQL database (an in-memory DB would be better). – Szymon Jednac Mar 07 '13 at 19:39
  • In web.xml: mode="aspectj" solved my problem on the row `` – user1805440 Mar 19 '13 at 15:34