dev@glassfish.java.net

Re: The bulk operations...

From: Wonseok Kim <guruwons_at_gmail.com>
Date: Tue, 18 Jul 2006 10:08:51 +0900

Hi, Dyego

There is no INSERT in JPQL and there is no bulk INSERT in SQL as you know.

Other way to insert new rows into database other than em.persist(entity) is
native query like

em.createNativeQuery("INSERT INTO table VALUES (...)").executeQuery();

You need to execute native query repetitively to insert several rows.

It would be better if there is some way like below, but unfortunately there
is no such support in current JPA.

Queries queries = em.createNativeQueries();
queries.add("INSERT INTO table VALUES (xxx)");
queries.add("INSERT INTO table VALUES (xxx)");
...
queries.executeQueries();

- Wonseok

On 7/18/06, Dyego Souza Dantas Leal <dyego.leal_at_gmail.com> wrote:
>
> Hello guys of GlassFish
>
> The JPA Spec supports bulk operations like:
>
> UPDATE
> DELETE
>
>
> But... supports INSERT ? any example ?
>
>
> ps: i want to put 2.000 objets on database and need more speed on
> insert...
> any sugestions ?
>
> the em.save(obj) is too slow to put 2.000 objects in SAME TIME.
>
>
> Tnks in advance !
>
> --
>
>
>
> -------------------------------------------------------------------------
> ++ Dyego Souza Dantas Leal ++ Dep. Desenvolvimento
> -------------------------------------------------------------------------
> E S C R I B A I N F O R M A T I C A
> *** http://javacoffe.blogspot.com ***
> -------------------------------------------------------------------------
> The only stupid question is the unasked one (somewhere in Linux's HowTo)
> Linux registred user : #230601
> -- ICQ : 1647350
> $ look into "my eyes" Phone : +55 041 2106-1212
>
> look: cannot open my eyes Fax : +55 041 3296-6640
> -------------------------------------------------------------------------
> Reply: dyego_at_escriba.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>