Mukul
Mukul

Reputation: 11

Why there is no insert query in jpql

I am using dropwizard hibernate and there I am using @NamedQuery() I didn't find any source to put my data into my database

Upvotes: 0

Views: 3006

Answers (2)

Eric Green
Eric Green

Reputation: 1293

You can do INSERT with HQL (Hibernate Query Language):

Statement types

Both HQL and JPQL allow SELECT, UPDATE and DELETE statements to be performed. HQL additionally allows INSERT statements, in a form similar to a SQL INSERT FROM SELECT.

See: HQL and JPQL

Upvotes: 0

Robert Niestroj
Robert Niestroj

Reputation: 16141

To put data into the database the Hibernate way use the EntityManager interface. It has two methods to put data into the database:

<T> T merge(T entity)

void persist(Object entity)

Upvotes: 0

Related Questions