Note that there are some explanatory texts on larger screens.

plurals
  1. POError insert element (primary key)
    text
    copied!<p>I have one problem with my configuration of play framework, when I insert a new <code>Notification</code> I have received the error. I don´t know why this error occured. Because I extends <code>Model</code> class, Play must generated a new ID for each row.</p> <p>If you can say to me what is the problem, or other better way to do this, Maybe if I extends the <code>GenericModel</code> and I do the code that is commented like this:</p> <pre><code>// @Id // @GeneratedValue(strategy = GenerationType.AUTO) // public long id; </code></pre> <p>but if I do this, How I must do the insert a new row?</p> <p>Thanks a lot!!!!</p> <hr> <p>Error found:</p> <blockquote> <p><strong>PersistenceException occured</strong> : <code>org.hibernate.HibernateException</code>: The database returned no natively generated identity value</p> </blockquote> <p>This is <code>/app/controllers/WSConfiguracion.java</code> :</p> <pre><code>if (cliente.valorBateria &lt; filasConfiguracionClientes.get(i).limiteBateria) { if (!estadoNotificacion.hayNotiBateria) { // code below generated the error Notificacion notificacion = new Notificacion( filasConfiguracionClientes.get(i).imeiadmin,imei, "bateria baja" ).save(); estadoNotificacion.hayNotiBateria = true; //notificacion.save(); estadoNotificacion.save(); renderText("NOTIFICA BATERIA"); } } else { ... } </code></pre> <h3>This is my model.</h3> <pre><code>package models; import javax.persistence.Entity; import play.db.jpa.Model; @Entity public class Notificacion extends Model { //@Id //@GeneratedValue(strategy = GenerationType.AUTO) //public long id; //@Id public long imeiadmin; //@Id public long imeiclient; public String detalleNotificacion; public Notificacion(long imeiadmin, long imeiclient,String detalleNotificacion) { this.imeiadmin = imeiadmin; this.imeiclient = imeiclient; this.detalleNotificacion = detalleNotificacion; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload