I've mapped a table (mapping is correct) and now I want to add new row into this table. First of all I've binded all columns of table.
cb_acc_type.valueProperty().bindBidirectional(model.accTypeProperty());
tf_acc_num.textProperty().bindBidirectional(model.accNumProperty());
tf_acc_name.textProperty().bindBidirectional(model.accNameProperty());
cb_currency_add.valueProperty().bindBidirectional(model.accCurProperty());
and added them into @ActionMethod
@ActionMethod(ACTION_ADD_ACCOUNT)
public void addAccount() {
CreateAccount input = new CreateAccount();
input.setType(model.getAccType());
input.setAccNum(model.getAccNum());
input.setAccName(model.getAccName());
input.setCurrency(model.getAccCur());
service.addAccount(input, context.getTaskView(), result -> {
model.getAccounts().addAll(result.getAccount());
tv_loro_nostro_accounts.getSelectionModel().selectFirst();
});
}
Here is what addAccount()
method do
public void addAccount(CreateAccount input, FOTaskView view, final FOAsyncTaskCallback<CreateAccount> callback){
HttpPostJsonTask<CreateAccount, CreateAccount> task = factory.httpPostForJson(FOContext.getLocalMessage("service.main.load_menu_operation"), "position/createAccount", input, view);
task.setOnSucceeded(event -> {
if (callback != null) {
callback.onSuccess((CreateAccount) event.getSource().getValue());
}
});
context.getExecutor().submit(task);
}
afterwards I do this
@Path("createAccount")
@POST
public CreateAccount createAccount(CreateAccount model){
model = operationService.execute(model,(result, userDetails) -> {
result.setAccount(service.createAccount(result.getAccount()));
result.setState(OperationState.DONE);
return result;
});
return model;
}
where createAccount() method is
public PositionAccount createAccount(PositionAccount account){
repository.createAccount(account);
return account;
}
and finally in repository
I do this
public void createAccount(PositionAccount account){
em.persist(account);
em.refresh(account);//em - EntityManager
}
PositionAccount
is a mapped class. What can be wrong with this? Here what it writes in a console
19:36:23.825 [pool-2-thread-1] INFO jersey - [] 11 * Sending client request on thread pool-2-thread-1
11 > POST http://localhost:8081/isbankInbound/issystem/position/createAccount
11 > Accept: application/json
11 > Content-Type: application/json
{
"@class" : "ru.com.isbank.adc.adc_common.operations.position.CreateAccount",
"sessionId" : "e8a5a3cb-26ce-44af-89d0-15e5c3457dfd",
"operatorId" : "sm10155",
"dateTimeSent" : 1436373383817,
"locale" : "ru_RU",
"type" : "Loro",
"accNum" : "someaccnum",
"accName" : "someaccname",
"currency" : "EUR"
}
19:36:23.927 [pool-2-thread-1] INFO jersey - [] 12 * Client response received on thread pool-2-thread-1
12 < 500
12 < Connection: close
12 < Content-Length: 0
12 < Date: Wed, 08 Jul 2015 16:36:23 GMT
12 < Server: Apache-Coyote/1.1