-->
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.  [ 6 posts ] 
Author Message
 Post subject: Error occurs when bean with setter of float datatype is used
PostPosted: Wed Oct 05, 2005 8:08 am 
Newbie

Joined: Wed Oct 05, 2005 7:54 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:oracle9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of bus.LH_M_EBooking.Booking.setPi_pkgs; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of bus.LH_M_EBooking.Booking.setPi_pkgs
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of bus.LH_M_EBooking.Booking.setPi_pkgs
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:749)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:740)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:732)
at db.LH_M_EBooking.EBookingHibernate.getQuerylist(EBookingHibernate.java:17)
at bus.LH_M_EBooking.Bookingmanager.Query(Bookingmanager.java:55)
at web.Exportbookingcontroller.HQuery(Exportbookingcontroller.java:363)
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 uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:381)
at uk.ltd.getahead.dwr.impl.DefaultProcessor.doExec(DefaultProcessor.java:539)
at uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:87)
at uk.ltd.getahead.dwr.DWRServlet.doPost(DWRServlet.java:174)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.cglib.beans.BulkBeanException
at bus.LH_M_EBooking.Booking$$BulkBeanByCGLIB$$b986e45a.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
... 53 more
Caused by: java.lang.NullPointerException
... 55 more


Hai Every one this is the error i get if i include a datatype of float what may be the cause.

Can anyone help me

Thanks
Aniesh U.K


Top
 Profile  
 
 Post subject: Re: Error occurs when bean with setter of float datatype is
PostPosted: Wed Oct 05, 2005 8:24 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
If you are using Primitives as attributes, and the database contains a NULL value, Hibernate won't know how to handle this since a Primitive can't represent a NULL value.

The BasicPropertyAccessor uses the following code to set property values
Code:
public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {
         try {
            method.invoke( target, new Object[] { value } );
         }
         catch (NullPointerException npe) {
            if ( value==null && method.getParameterTypes()[0].isPrimitive() ) {
               throw new PropertyAccessException(npe, "Null value was assigned to a property of primitive type", true, clazz, propertyName);
            }
            else {
               throw new PropertyAccessException(npe, "NullPointerException occurred while calling", true, clazz, propertyName);
            }
         }
...
...


You should either use Wrapper classes or create a custom PropertyAccessor to define your default behavior.

If you want NULL database values to default to say 0.0, you can add logic inside the try {} to check for this condition.
Code:
    if (value == null) {
        return; // do nothing (alternatively, set to some default value)
    } else {
        method.invoke( target, new Object[] { value } ); //This is only line in BasicPropertyAccessor.BasicSetter
    }   

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 8:55 am 
Newbie

Joined: Wed Oct 05, 2005 7:54 am
Posts: 8
Hai

Very thanks for u r reply.I am a newbie.I am using spring and hibernate.I really can't go with u.Can u say me in detail or with some little clue.Help pls


Thanks
Have a nice day
Aniesh U.K


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 8:56 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Simple terms.

If possible use Float instead of float.

Otherwise you'll have to use the methods outlined above.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 11:52 pm 
Newbie

Joined: Wed Oct 05, 2005 7:54 am
Posts: 8
Hai all ,

Thanks for u r kind reply.I used Float instead of float it worked fine.What about int datatype.Should i use any conventions.

Help needed urgently.


Thanks(Have a nice day)
Aniesh U.K


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 12:05 am 
Newbie

Joined: Wed Oct 05, 2005 7:54 am
Posts: 8
Hai all

I found the answer Hope i need to use Integer instead of int.

Is this right.


Thanks
Aniesh U.K


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.