String sql = "from CreditCard where siteId = :siteId order by creditCardId";
Query query = em.createQuery(sql);
query.setParameter("siteId", Constants.SITE_SYSTEM);
Iterator<?> iterator = query.getResultList().iterator();
while (iterator.hasNext()) {
CreditCard master = (CreditCard) iterator.next();
CreditCard creditCard = new CreditCard();
PropertyUtils.copyProperties(creditCard, master);
creditCard.setSite(site);
creditCard.setCreditCardId(null);
creditCard.setRecUpdateBy(userId);
creditCard.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
creditCard.setRecCreateBy(userId);
creditCard.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(creditCard);
}
}