Session ssn = HibernateUtils.getSession();
try{
HibernateUtils.beginTransaction();
List rpls = ssn.createQuery("FROM TopicReplyBean AS r ORDER BY r.id").list();
for(int i=0;i<rpls.size();i++){
TopicReplyBean rpl = (TopicReplyBean)rpls.get(i);
CommentBean cb = new CommentBean();
cb.setClient(rpl.getClient());
AuthorInfo author = new AuthorInfo();
author.setEmail(rpl.getAuthorEmail());
author.setName(rpl.getAuthor());
author.setUrl(rpl.getAuthorURL());
if(rpl.getUser()!=null){
author.setName(rpl.getUser().getNickname());
author.setId(rpl.getUser().getId());
}
else
author.setName("����");
cb.setAuthor(author);
cb.setContent(rpl.getContent());
cb.setCreateTime(rpl.getReplyTime());
cb.setEid(rpl.getTopic().getId());
cb.setEtype(DiaryReplyBean.TYPE_BBS);
cb.setSite(rpl.getSite());
cb.setStatus(rpl.getStatus());
cb.setTitle(rpl.getTitle());
ssn.save(cb);
System.out.println("TopicReplyBean: " + rpl.getId() + " -> " + cb.getId());
}
HibernateUtils.commit();
}catch(Exception e){
HibernateUtils.rollback();
throw e;