0

I have a file which i want to import to the postgres database. I know i can do it with jdbc and copymanager.

My Question is, how can i do it when i'm using JPA.

EntityManager em = JpaUtil.createEntityManager();
    em.getTransaction().begin();

    System.out.println(file2);
    Query copyQuery = em.createQuery("COPY temp_import FROM STDIN WITH DELIMITER E'\t'" +file2);

This isn't working.

Thanks for Help.

0

1 Answer 1

2

I know i can do it with jdbc and copymanager.

My Question is, how can i do it when i'm using JPA.

No, you can't, except by unwrapping the JPA connection to get the underlying JPA provider session, then unwrapping that to get the pooled connection, then unwrapping that to get the underlying SQL connection, then casting that to PSQLConnection and getting the CopyManager API for it.

JPA doesn't have a bulk-loading API.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.