Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa ViewerSupport.bind不能正确处理实体_Jpa_Eclipse Rcp_Jface - Fatal编程技术网

Jpa ViewerSupport.bind不能正确处理实体

Jpa ViewerSupport.bind不能正确处理实体,jpa,eclipse-rcp,jface,Jpa,Eclipse Rcp,Jface,在我的RCP应用程序中,我有一个绑定到可写人员列表的TableViewer: input = new WritableList(ModelProvider.INSTANCE.getPersons(), Person.class); ViewerSupport.bind(viewer, input, BeanProperties.values(new String[] { "firstName", "lastName", "married" })); 如果我在getPersons中创建perso

在我的RCP应用程序中,我有一个绑定到可写人员列表的TableViewer:

input = new WritableList(ModelProvider.INSTANCE.getPersons(), Person.class);
ViewerSupport.bind(viewer, input, BeanProperties.values(new String[] { "firstName", "lastName", "married" }));
如果我在getPersons中创建persons,那么在我的tableviewer中一切都很好。我可以修改一个条目,修改后,新值将在表中标记。 getPersons:

persons = new ArrayList<Person>();
persons.add(new Person("Rainer", "Zufall", "male", true));
persons.add(new Person("Reiner", "Babbel", "male", true));
persons.add(new Person("Marie", "Dortmund", "female", false));
return persons;
factory = persistenceProvider.createEntityManagerFactory(PERSISTENCE_UNIT_NAME,map);
entityManager = factory.createEntityManager();
Query q = entityManager.createQuery("select p from Person p");
List<Person> persons = q.getResultList();
entityManager.close();
return persons;
但是,如果persons将从EntityManager返回,则修改的条目将不会在表中标记,尽管Person对象中的字段将被设置。 getPersons:

persons = new ArrayList<Person>();
persons.add(new Person("Rainer", "Zufall", "male", true));
persons.add(new Person("Reiner", "Babbel", "male", true));
persons.add(new Person("Marie", "Dortmund", "female", false));
return persons;
factory = persistenceProvider.createEntityManagerFactory(PERSISTENCE_UNIT_NAME,map);
entityManager = factory.createEntityManager();
Query q = entityManager.createQuery("select p from Person p");
List<Person> persons = q.getResultList();
entityManager.close();
return persons;