Hi,

my enviroments:
JBoss AS 4.2.0.GA
Seam 2.0.0.BETA1(CVS)
Seam gen-generated project

When DetachedCriteria#getExecutableCriteria in the following code is invoked,
"java.lang.ClassCastException: 
org.jboss.seam.persistence.FullTextHibernateSessionProxy" is thrown.
This code worked with Seam1.3.0.ALPHA.

  | @Name("criteriaTesting")
  | @Scope(ScopeType.CONVERSATION)
  | public class CriteriaTestingBean implements Serializable {
  |     @In
  |     private EntityManager entityManager;
  |     
  |     private Integer minAge;
  |     private Integer maxAge;
  |     
  |     @Out(required=false)
  |     private List<Member> members;
  |     
  | 
  |     public void setMinAge(Integer minAge) {
  |         this.minAge = minAge;
  |     }
  |     
  |     public void setMaxAge(Integer maxAge) {
  |         this.maxAge = maxAge;
  |     }
  |     
  |     public void search() {
  |         Session session = (Session) entityManager.getDelegate();
  |         
  |         DetachedCriteria crit = DetachedCriteria.forClass(Member.class);
  | 
  |         if (minAge != null) {
  |             crit.add( ge("age", minAge) );
  |         }
  |         if (maxAge != null) {
  |             crit.add( le("age", maxAge) );
  |         }
  |         
  |         members = crit.getExecutableCriteria(session).list();
  |     }
  | }
  | 

The following: stack trace

  |    [testng] java.lang.ClassCastException: 
org.jboss.seam.persistence.FullTextHib
  | ernateSessionProxy
  |    [testng]     at 
org.hibernate.criterion.DetachedCriteria.getExecutableCriteri
  | a(DetachedCriteria.java:52)
  |    [testng]     at 
seam.study.criteria.CriteriaTestingBean.search(CriteriaTestin
  | gBean.java:66)
  |    [testng]     at 
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
  |    [testng]     at 
org.jboss.seam.intercept.RootInvocationContext.proceed(RootIn
  | vocationContext.java:31)
  |    [testng]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamIn
  | vocationContext.java:56)
  |    [testng]     at 
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(Bijecti
  | onInterceptor.java:46)
  |    [testng]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamIn
  | vocationContext.java:68)
  |    [testng]     at 
org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.a
  | roundInvoke(ManagedEntityIdentityInterceptor.java:43)
  |    [testng]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamIn
  | vocationContext.java:68)
  |    [testng]     at 
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(R
  | ollbackInterceptor.java:31)
  |    [testng]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamIn
  | vocationContext.java:68)
  |    [testng]     at 
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(Met
  | hodContextInterceptor.java:42)
  |    [testng]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamIn
  | vocationContext.java:68)
  |    [testng]     at 
org.jboss.seam.intercept.RootInterceptor.invoke(RootIntercept
  | or.java:106)
  |    [testng]     at 
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocat
  | ion(JavaBeanInterceptor.java:151)
  |    [testng]     at 
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanI
  | nterceptor.java:87)
  |    [testng]     at 
seam.study.criteria.CriteriaTestingBean_$$_javassist_2.search
  | (CriteriaTestingBean_$$_javassist_2.java)
  |    [testng]     at 
seam.study.test.criteria.CriteriaTest$1.invokeApplication(Cri
  | teriaTest.java:30)
  |    [testng]     at 
org.jboss.seam.mock.BaseSeamTest$Request.invokeApplicationPha
  | se(BaseSeamTest.java:604)
  |    [testng]     at 
org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(
  | BaseSeamTest.java:556)
  |    [testng]     at 
org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.jav
  | a:487)
  |    [testng]     at 
seam.study.test.criteria.CriteriaTest.testSearch(CriteriaTest
  | .java:18)
  |    [testng] ... Removed 26 stack frames
  | 

The following(not DetachedCriteria version) works fine with Seam 2.0.0.BETA1.

  |     public void search() {
  |         Session session = (Session) entityManager.getDelegate();
  |         
  |         Criteria crit = session.createCriteria(Member.class);
  |         
  |         if (minAge != null) {
  |             crit.add( ge("age", minAge) );
  |         }
  |         if (maxAge != null) {
  |             crit.add( le("age", maxAge) );
  |         }
  |         
  |         members = crit.list();
  |     }
  | 

Do I make a mistake in how to use DetachedCriteria in Seam app?
Thanks in advance.



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061665#4061665

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4061665
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to