Query in JPQL for insertion of Data

1

How can I insert data with JPQL containing values:

 @Query("insert into user values()")
    User insertUser();

Data:     username     emailUser

    
asked by anonymous 16.08.2016 / 17:40

1 answer

1

In this way:

String query = "insert into User values(?,?)";

EntityManager em = emf.createEntityManager();
em.createNativeQuery(query)
   .setParameter(1, "maria")
   .setParameter(2, "123456")
   .executeUpdate();
    
17.08.2016 / 14:40