-
1. Re: fetchtype.LAZY results in JSF validation error
pmuir Nov 4, 2006 5:20 PM (in response to roeber)Some suggestions:
1) Association fetching in Hibernate is lazy by default AFAIK
2) How are you getting the EntityManager in your converter? I had problems with getting a reference to the EntityManager from JNDI and found that getting an EntityManagerFactory from JNDI worked better (otherwise the entity became detached)
3) '"xxx": Value is not a valid option' validation error occurs because the newly submitted converted selection is not a member of the original list. Have you overridden equals() on the OrgUnit so that it uses Id equality rather than object equality (you create a new OrgUnit from the database when you em.find()).
4) You could try the EntityConverter as it does this all for you for any EJB3 entity.
HTH -
2. Re: fetchtype.LAZY results in JSF validation error
roeber Nov 5, 2006 1:32 AM (in response to roeber)Thx for your suggestions. Encouraged by your suggestion 3 I have debugged my overridden equals method once again (ignoring the tracing output). What I found out:
other.name is null where it shouldn't be null. Changing this line to other.getName() fixed the problem!public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof OrgUnit)) return false; final OrgUnit other = (OrgUnit) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; }
"petemuir" wrote:
1) Association fetching in Hibernate is lazy by default AFAIK
Are you sure? This would make things strange anymore.
But now I know that this is an Hibernate issue - not a Seam issue.
Thanks! -
3. Re: fetchtype.LAZY results in JSF validation error
pmuir Nov 6, 2006 4:40 AM (in response to roeber)"roeber" wrote:
"petemuir" wrote:
1) Association fetching in Hibernate is lazy by default AFAIK
Are you sure? This would make things strange anymore.
Yep.
http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#d0e1570
http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-lazy -
4. Re: fetchtype.LAZY results in JSF validation error
mustaghattack Jun 4, 2007 6:24 AM (in response to roeber)
3) '"xxx": Value is not a valid option' validation error occurs because the newly submitted converted selection is not a member of the original list. Have you overridden equals() on the OrgUnit so that it uses Id equality rather than object equality (you create a new OrgUnit from the database when you em.find()).
Using Id equality is not recommended AFAIK (http://www.hibernate.org/109.html) -
5. Re: fetchtype.LAZY results in JSF validation error
asavitsky Jun 4, 2007 10:40 AM (in response to roeber)"petemuir" wrote:
"roeber" wrote:
"petemuir" wrote:
1) Association fetching in Hibernate is lazy by default AFAIK
Are you sure? This would make things strange anymore.
Yep.
http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#d0e1570
http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-lazy
Nope.
Quoting from the first link (section 2.2.5.5):@OneToMany and @ManyToMany associations are defaulted to LAZY and @OneToOne and @ManyToOne are defaulted to EAGER
and he had a @ManyToOne in his code, which is EAGER by default, not LAZY.