Ver Mensaje Individual
  #10 (permalink)  
Antiguo 11/11/2013, 08:31
Avatar de lozanoguido
lozanoguido
 
Fecha de Ingreso: junio-2011
Mensajes: 33
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: Hibernate - Consulta sobre

Bien! cambie todos los long por Integer por que la verdad no se para que le habia puesto long a esos atributos y dejo de arrojarme dicho error! :) muchas gracias por la info que me han dado!

ahora, les hago una consulta, tengo este problema:

Hibernate: select productosl0_.codigo as codigo12_, productosl0_.descripcion as descripc3_12_, productosl0_.precio as precio12_, productosl0_.relacion_vp as relacion5_12_ from productos productosl0_ where productosl0_.tipo='PL'
Hibernate: insert into pedidos (codigo_cliente, estado) values (?, ?)
Hibernate: update detalle_pedidos set codigo_pedido=?, descripcion=?, cantidad=?, peso=?, volumen=? where id=?
Nov 11, 2013 11:32:35 AM org.hibernate.engine.jdbc.batch.internal.AbstractB atchImpl release
INFO: HHH000010: On release of batch it still contained JDBC statements
Nov 11, 2013 11:32:35 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet appServlet threw exception
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.c heckBatched(Expectations.java:81)
at org.hibernate.jdbc.Expectations$BasicExpectation.v erifyOutcome(Expectations.java:73)
at org.hibernate.engine.jdbc.batch.internal.NonBatchi ngBatch.addToBatch(NonBatchingBatch.java:57)
at org.hibernate.persister.entity.AbstractEntityPersi ster.update(AbstractEntityPersister.java:3017)
at org.hibernate.persister.entity.AbstractEntityPersi ster.updateOrInsert(AbstractEntityPersister.java:2 919)
at org.hibernate.persister.entity.AbstractEntityPersi ster.update(AbstractEntityPersister.java:3248)
at org.hibernate.action.internal.EntityUpdateAction.e xecute(EntityUpdateAction.java:140)
at org.hibernate.engine.spi.ActionQueue.execute(Actio nQueue.java:362)
at org.hibernate.engine.spi.ActionQueue.executeAction s(ActionQueue.java:354)
at org.hibernate.engine.spi.ActionQueue.executeAction s(ActionQueue.java:276)
at org.hibernate.event.internal.AbstractFlushingEvent Listener.performExecutions(AbstractFlushingEventLi stener.java:326)
at org.hibernate.event.internal.DefaultFlushEventList ener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionIm pl.java:1214)
at org.hibernate.internal.SessionImpl.managedFlush(Se ssionImpl.java:403)
at org.hibernate.engine.transaction.internal.jdbc.Jdb cTransaction.beforeTransactionCommit(JdbcTransacti on.java:101)
at org.hibernate.engine.transaction.spi.AbstractTrans actionImpl.commit(AbstractTransactionImpl.java:175 )
at org.springframework.orm.hibernate4.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:480)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:723)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:394)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:120)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:622)
at local.dao.PedidoDao$$EnhancerByCGLIB$$6a8df73e_2.s ave(<generated>)
at local.controller.PedidoController.finishP(PedidoCo ntroller.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHa ndlerMethod.invoke(InvocableHandlerMethod.java:213 )
at org.springframework.web.method.support.InvocableHa ndlerMethod.invokeForRequest(InvocableHandlerMetho d.java:126)
at org.springframework.web.servlet.mvc.method.annotat ion.ServletInvocableHandlerMethod.invokeAndHandle( ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotat ion.RequestMappingHandlerAdapter.invokeHandlerMeth od(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotat ion.RequestMappingHandlerAdapter.handleInternal(Re questMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.Abstrac tHandlerMethodAdapter.handle(AbstractHandlerMethod Adapter.java:80)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:723)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


Como veo intenta hacer un UPDATE a la base de datos...como podria hacer para que haga directamente un insert?

Es por algun atributo que le estoy indicando en el mapeo?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="local.model.Pedido" table="pedidos">
<id column="codigo" name="codigo">
<generator class="native"/>
</id>
<many-to-one name="cliente" column="codigo_cliente" class="local.model.Cliente" not-null="true"/>
<property column="estado" name="estado" />
<set name="listadodeproductos" inverse="true" lazy="true" cascade="all">
<key column="codigo_pedido"/>
<one-to-many class="local.model.ProductoForm"/>
</set>
</class>
</hibernate-mapping>


Desde ya muchas gracias!!