Here is my code part:
Query q = em.createNativeQuery(\"insert into table_name (value_one, value_two, value_three) values (?,?,?)\");
q.setParameter(1, value1
if you are not using Hibernate, but you are using EclipseLink you can use the query Hint: https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Query_Hints
Example query:
String insert = "INSERT INTO mytable VALUES ( ?, ?, ?, ?)";
em = getEntityManager();
em.getTransaction().begin();
Query u = em.createNativeQuery(insert);
u.setHint(QueryHints.BIND_PARAMETERS, HintValues.FALSE);//<--the hint
u.setParameter(1, "value1");
u.setParameter(2, "value2");
u.setParameter(4, "value4");//just skipped the null element
u.executeUpdate();
em.getTransaction().commit();
and the result will be an insertion:
mytable
column1 column2 column3 column4
value1 value2 value4
of course if "column3" is nullable in the db...
I don't know if works also with Hibernate, but it could. I used PostgreSQL for my test.