String sql = "from Report report where report.site.siteId = 'default' and systemRecord = 'Y'";
Query query = em.createQuery(sql);
Iterator<?> iterator = query.getResultList().iterator();
while (iterator.hasNext()) {
Report masterReport = (Report) iterator.next();
Report report = new Report();
report.setSite(site);
report.setReportName(masterReport.getReportName());
report.setReportDesc(masterReport.getReportDesc());
report.setReportText(masterReport.getReportText());
report.setSystemRecord(Constants.VALUE_YES);
report.setRecUpdateBy(userId);
report.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
report.setRecCreateBy(userId);
report.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(report);
}
sql = "from IeProfileHeader ieProfileHeader where ieProfileHeader.site.siteId = 'default' and systemRecord = 'Y'";
query = em.createQuery(sql);