This content has been marked as final.
Show 3 replies
-
1. Re: Use criteria in a seam action class ?
ralf Apr 23, 2009 1:27 PM (in response to giannisapi)Hey,
i faced the problem too and after some tryouts i found a solution.
Try that:
HibernateSessionProxy proxy = (HibernateSessionProxy) this.entityManager.getDelegate(); Criteria criteria = proxy.createCriteria( MyClass.class );
Does it work??
Ralf
-
2. Re: Use criteria in a seam action class ?
gonorrhea Apr 24, 2009 1:24 AM (in response to giannisapi)Seam in Action:
When you’re using JPA, you can always get down to the provider interface by calling the getDelegate() method on the EntityManager instance. But you have to perform a cast that makes an assumption about the underlying JPA provider: Session session = (Session) entityManager.getDelegate(); You can define a factory in Seam to hide the cast: <factory name="hibernateSession" value="#{entityManager.delegate}" auto-create="true"/> You then use the @In annotation to inject the value of this factory into your component: @In private Session hibernateSession;
-
3. Re: Use criteria in a seam action class ?
giannisapi Apr 24, 2009 1:18 PM (in response to giannisapi)Hi all,
First of all thanks for the replies.
Sorry for the late post but my pc motherboard burnt out so i had to replace it...
The proxy thing seems to be working for me. But this:
'<facory name="hibernateSession" value="#{entityManager.delegate}" auto-create="true"/> '
I dont really understand it . So i will have to use sessionproxy.
just one more question. Performance wise, which of the two sollutions iis better?
Regards,
gianis