Kukuh Indrayana
Kukuh Indrayana

Reputation: 204

how to commit updated data (vaadin jpacontainer)

i'm new to vaadin jpacontainer. I'm using vaadin jpacontainer agpl-3.0-2.10.

I have made a Person class, and my application class look like this:

EntityManager em = JPAContainerFactory.createEntityManagerForPersistenceUnit("book-examples");

JPAContainer<Person> persons = JPAContainerFactory.make(Person.class, "book-examples");
persons.setReadOnly(false);

persons.addEntity(new Person("Marie-Louise Meilleur", 117));
persons.addEntity(new Person("Sarah Knauss", 122));

Table personTable = new Table("person",persons);
personTable.setReadOnly(false);

persons.getItem(1L).getEntity().setName("Me");
persons.commit();
personTable.commit();
layout.addComponent(personTable);

When i run the application, the result is as i hoped: the first item's name is "Me". But when i check the database, the first item's name is "Marie-Louise Meilleur". Why the commit method didn't change the database?

Upvotes: 0

Views: 2657

Answers (1)

Kukuh Indrayana
Kukuh Indrayana

Reputation: 204

ah, just wrong method. It should be persons.getItem(1L).getItemProperty("name").setValue("me");

Upvotes: 2

Related Questions