-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Example.setPropertySelector and excludeProperty() errors
PostPosted: Mon Apr 19, 2004 8:59 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi,

I receive the following error when trying to use a setPropertySelector class or an excludeProperty() for an Example criteria :

Code:
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ... .dto.FilmTO.?


I've read the HibDocu and forum, but could not make it use. I use JBoss3.2.3 and have only one cglib version, that is located in the ear.

I have Hibernate2.1.2, with the latest cglib version, doesn't help.

What to do now? criteria is a very great tool for my needs, but I have to limit the loaded fields for speed.

looking for your help.

regards,
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 10:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
show more stacktrace.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 10:33 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi micheal,

michael wrote:
show more stacktrace.


here's a code snippet from my dao class:

Code:
      try {
         session = getSessions().openSession();
         tx = session.beginTransaction();

         Criteria crit = session.createCriteria(FilmTO.class);
         Example eg = Example.create(FilmTO.class)
            .setPropertySelector(new FilmProps());
            
         crit.add(eg);

         if (criterions!=null) while (criterions.hasNext()) crit.add((Criterion)criterions.next());
         if (orders!=null) while (orders.hasNext()) crit.addOrder((Order)orders.next());

         if (pageSize!=null && pageNumber!=null) {
            crit.setMaxResults(pageSize.shortValue());
            crit.setFirstResult(pageSize.shortValue() * pageNumber.shortValue());
         }
         
         ret = crit.list();
         session.flush();
         tx.commit();
      } catch (HibernateException ex) {


and here's the filter class
Code:
   private class FilmProps implements Example.PropertySelector {
      public boolean include(Object propertyValue, String propertyName, Type type) {
         return !(propertyValue instanceof Collection);
      }
   }



and here the error stack trace:
Code:
java.rmi.ServerException: EJBException:; nested exception is:
   javax.ejb.EJBException: nested exception is: rnd.toma.dvdrider.dao.DataAccessException: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of rnd.toma.dvdrider.dto.FilmTO.?
   at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:347)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
   at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
   at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
   at org.jboss.ejb.Container.invoke(Container.java:700)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
   at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
   at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
   at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
   at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
   at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
   at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
   at $Proxy81.getFilmekByElozetes(Unknown Source)
   at rnd.toma.dvdrider.web.site.Welcome.doView(Welcome.java:54)
   at rnd.toma.dvdrider.web.site.Welcome.doGet(Welcome.java:43)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
   at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:575)
   at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498)
   at rnd.toma.dvdrider.web.site.Site.doDispatch(Site.java:50)
   at rnd.toma.dvdrider.web.site.Site.doGet(Site.java:31)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
   at java.lang.Thread.run(Thread.java:534)
Caused by: javax.ejb.EJBException: nested exception is: rnd.toma.dvdrider.dao.DataAccessException: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of rnd.toma.dvdrider.dto.FilmTO.?
   at rnd.toma.dvdrider.ejb.ListerBean.getFilmek(ListerBean.java:153)
   at rnd.toma.dvdrider.ejb.ListerBean.getFilmekByElozetes(ListerBean.java:103)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
   at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
   at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
   at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
   at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
   at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
   ... 66 more



thanks for dealing with this issue.

regards,
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 10:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is not caused by propertySelector, look at the stackTrace. I suspect you have a primitive type somewhere in your object and have it mapped to a db column which contains null values.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 3:55 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi micheal,

I've checked all my objects, not just FilmTO, and confirmed myself that all of my private fields stand for objects. I have no primitive field, nor any accessor method with primitive parameter.

Is there any other answer to the error?

Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 5:45 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi micheal,

the problem was that Example.create(Object entity) needs an entity Object not a class object. So I changed my code to

Code:
  FilmTO dto = new FilmTO();
  Example eg = Example.create(dto);


But now it returns 0 row. why is that?

I made the Cat example mentioned in the Hibernate Documentation and it also returns zero = 0 lines when adding an Example.create(cat) to the criteria.

why is that? how to receive all the lines?

looking for your help.

regards,
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 5:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Take a look at the generated SQL i'd suggest. I suspect some property is taken into account you are not expecting.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 7:15 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi micheal,

OK, I've found the error. in my propselector class I had to exclude zero values for Number objects and those null valued objects.

In the cat example, char primitive type property was the problem, exluding it, propertyselector works great.

thanks.

bye,
Thomas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.