简体   繁体   中英

Why there is no insert query in jpql

我正在使用dropwizard休眠,在那里我正在使用@NamedQuery()我找不到任何源来将数据放入数据库

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM