openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From opengloves <openglo...@gmail.com>
Subject Re: OpenJPA-2.0.0-snapshot Question with @ManyToMany
Date Tue, 02 Jun 2009 15:29:28 GMT

Jeremy Bauer,

Thanks for your help. Wonderful. 
Then the test is passed. I knew the reason.
Thans again.

---
Open Gloves


Jeremy Bauer wrote:
> 
> Open Gloves,
> 
> Apologies.  I did not verify that the insert into the collection actually
> took place.  After re-running the test, paying close attention to the
> trace
> output, I found the source of the problem.  During entity enhancement
> several warnings were logged of this form:
> 
> 1656  sample  WARN   [main] openjpa.Enhance - Detected the following
> possible violations of the restrictions placed on property access
> persistent
> types:
> "entities.Student" uses property access, but its field "teachers" is
> accessed directly in method "removeTeacher" defined in "entities.Student".
> 
> In short, non-persistent methods in Teacher and Student are accessing
> fields
> directly instead of calling the persistent property methods.  In order for
> OpenJPA to effectively track changes in the persistent properties they
> must
> be accessed instead of the fields.  Modifying the addTeacher and
> removeTeacher methods as below corrected the problem.
> 
>        public void addTeacher(Teacher teacher) {
>            if (getTeachers() == null)
>                setTeachers(new HashSet<Teacher>());
>            getTeachers().add(teacher);
>        }
>        public void removeTeacher(Teacher teacher) {
>            if (getTeachers().contains(teacher)) {
>                getTeachers().remove(teacher);
>            }
>        }
> 
> This looks to be another implementation difference between OpenJPA and
> Hibernate.
> 
> -Jeremy
> 
> 

-- 
View this message in context: http://n2.nabble.com/OpenJPA-2.0.0-snapshot-Question-with-%40ManyToMany-tp3006387p3012730.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message