Hi all
I got Hql string which contain query that return List<String>,
Each String is the identifier row METADATA table.
Quote:
SELECT md.id FROM MetaData as md WHERE md.metadataType ="X";
METADATA table description:
Quote:
MetaData tabe :
String id, String metadataType , Date metadataChangeDate , String MetaDataText
The HQL query may result in thousands to several million records of identifiers ids.
After I get the List of metadata ids I divide them to 1000 and insert it to another table (bulk table) for later processing.
Performance and speed is the main issue here,
The question is should I get all records at once using:
(Pseudo code)
Code:
Query query = getEntityManager().createNamedQuery("SelectTypeXFromMetaData");
query.setParameter(x,'x');
List<String> = query.list ()
Loop on the list:
Create 1000 bulks
Insert into the bulk table
Or it will be faster to tell the query to divide the result 1000 each time?
Example:
Code:
Query query = getEntityManager().createNamedQuery("SelectTypeXFromMetaData");
query.setParameter(x,'x');
while (list contain items){
query.setFirstResult(start);
query.setMaxResults(rowNum);
List<String> = query.list ()
Insert into the bulk table
}
Another alternative is JDBC or oracle stored proc,
Please advise
Thank you very much!
Sharon