Reputation: 1123
I'm trying to write a function to update existing rows in a table with ebean. I instantiate a new Ebean model object, give it the existing ID, add the properties I want to change, then send Ebean an update request. However, the update is not sent to the database. What could be the issue here?
EB_Datasource ebds = new EB_Datasource();
ebds.id = 100;
ebds.databaseName = "NewValue";
ebds.update();
System.out.println("test values: " + ebds.databaseName);
ebds.refresh();
System.out.println("test values: " + ebds.databaseName);
The results of the print statements are:
test values: NewValue
test values: OriginalValue
What could be the issue here? Why isn't update doing its job?
Upvotes: 1
Views: 74
Reputation: 4031
ebds.id = 100;
ebds.databaseName = "NewValue";
Ebean does not support setting fields. You may have seen examples using the Play framework and in those cases it is the Play framework enhancement that is changing public field get/put into method calls calling setter/getter methods.
So in Ebean without Play you should be using getters/setters.
ebds.setId(100);
ebds.setDatabaseName("NewValue");
ebds.update();
Upvotes: 1