Hi, in my
java web apps, I used
JBoss, Seam with hibernate,
I used createNativeQuery and SELECT FROM .... to get records from a DB2 table, it works well. I can get all records.
Now, after I got the records, I want to insert some of data to another table, I tried to use createNativeQuery with INSERT INTO statement, something like this:
here, codes get the list or collection from CreateNativeQuery("Select * from table1");
start to loop from the list here.
EntityManager em = emf.createEntityManager();
EntityTransaction tx = null;
try {
tx = em.getTransaction(); //I got runtime error here, it says I can not use getTransaction error,
tx.begin();
// start to insert the record something like: createNativeQuery("INSERT INTO ..... table2");
....
Could you anybody help me how to resolve this problem with some examples? thanks a lot