Ver Mensaje Individual
  #18 (permalink)  
Antiguo 10/05/2017, 22:44
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Respuesta: Guardar OneToMany Hibernate

Hola a todos estuve probando y viendo un poco al hacer esto:

Código Java:
Ver original
  1. public void delVenta(Venta v){
  2.         ventas.remove(v);
  3.         v.setKey(null);
  4.     }

Me da este error:

ERROR: HHH000346: Error during managed flush [org.hibernate.HibernateException: identifier of an instance of app.model.entity.Venta was altered from app.model.entity.VentaKey@476435fd to null]

pero si hago esto:

Código Java:
Ver original
  1. public void delVenta(Venta v){
  2.         v.setKey(null);
  3.         ventas.remove(v);        
  4.     }

me da este error:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at app.vistas.modelos.ModeloVenta.getValueAt(ModeloVe nta.java:64)
at javax.swing.JTable.getValueAt(JTable.java:2717)
at javax.swing.JTable.prepareRenderer(JTable.java:570 6)

Sé que estoy fallando en algo, pero comienzo a pensar que los frameworks de Java me están rechazando xq con JPA no me andaba, y con hibernate que estoy intentando aprender a usarlo pasa esto.

Espero sus respuestas y saludos.