lefevre00 / parking

Share your place
https://takemyplace.herokuapp.com/
GNU Lesser General Public License v3.0
3 stars 4 forks source link

Réservation d'une place libérée #110

Closed vwilliam closed 8 years ago

vwilliam commented 8 years ago

Avec la version standalone, je libére une place avec un utilisateur ayant une place. Lorsque je me loggue avec un utilisateur sans place et que je veux en réserver une, il y a un plantage erreur 500 avec la log suivante :

org.springframework.orm.hibernate5.HibernateSystemException: Error accessing field [protected java.lang.String org.friends.app.model.Place$PlacePK.occupationDate] by reflection for persistent property [org.friends.app.model.Place$PlacePK#occupationDate] : Place [placeNumber=141, usedBy=null, occupationDate=2016-08-26]; nested exception is org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [protected java.lang.String org.friends.app.model.Place$PlacePK.occupationDate] by reflection for persistent property [org.friends.app.model.Place$PlacePK#occupationDate] : Place [placeNumber=141, usedBy=null, occupationDate=2016-08-26] at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:258) at org.springframework.orm.hibernate5.HibernateExceptionTranslator.convertHibernateAccessException(HibernateExceptionTranslator.java:57) at org.springframework.orm.hibernate5.HibernateExceptionTranslator.translateExceptionIfPossible(HibernateExceptionTranslator.java:44) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at org.friends.app.dao.impl.PlaceDaoImpl$$EnhancerBySpringCGLIB$$f0a5f007.update() at org.friends.app.service.impl.PlaceServiceBean.book(PlaceServiceBean.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy77.book(Unknown Source) at org.friends.app.view.route.BookRoute.doHandle(BookRoute.java:47) at org.friends.app.view.route.AuthenticatedRoute.handle(AuthenticatedRoute.java:26) at spark.TemplateViewRouteImpl$1.handle(TemplateViewRouteImpl.java:66) at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:162) at spark.servlet.SparkFilter.doFilter(SparkFilter.java:122) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:827) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [protected java.lang.String org.friends.app.model.Place$PlacePK.occupationDate] by reflection for persistent property [org.friends.app.model.Place$PlacePK#occupationDate] : Place [placeNumber=141, usedBy=null, occupationDate=2016-08-26] at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:71) at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:58) at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:64) at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:95) at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:438) at org.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:379) at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:332) at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:53) at org.hibernate.hql.internal.ast.exec.BasicExecutor.doExecute(BasicExecutor.java:82) at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:59) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:429) at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:374) at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1471) at org.hibernate.query.internal.AbstractProducedQuery.doExecuteUpdate(AbstractProducedQuery.java:1428) at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1406) at org.friends.app.dao.impl.PlaceDaoImpl.update(PlaceDaoImpl.java:42) at org.friends.app.dao.impl.PlaceDaoImpl$$FastClassBySpringCGLIB$$bf22ffed.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ... 44 more Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field org.friends.app.model.Place$PlacePK.occupationDate to org.friends.app.model.Place at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36) at java.lang.reflect.Field.get(Field.java:393) at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:67) ... 64 more

atamd commented 8 years ago

Le pb de la réservation est résolu en modifiant la méthode update dans PlaceDAOImpl, en remplaçant : .setParameter("id", new Place(place.getPlaceNumber(), place.getOccupationDate())) par : .setParameter("id", new Place.PlacePK(place.getPlaceNumber(), place.getOccupationDate())) Reste à revoir et corriger l'appel et la page affichée (book.ftl) suite à cette réservation !

atamd commented 8 years ago

correction ok