日期:2014-05-17 浏览次数:20753 次
Configuration conf = new Configuration().configure();
ServiceRegistryBuilder builder = new ServiceRegistryBuilder().applySettings(conf.getProperties());
ServiceRegistry registry = builder.buildServiceRegistry();
SessionFactory sf = conf.buildSessionFactory(registry);
Session sess = sf.getCurrentSession();
try{
this.setError((Error)sess.get(Error.class,error.getError_id()));
if( error.getReport_status()==1){
List lt= sess.createQuery("select distinct s from Solves as s where error =:error")
.setEntity("error", error)
.list();
this.setSolve((Solves)(lt.iterator().next()));
}
List lt = sess.createQuery("select distinct p from Platform as p")
.list();
for (Iterator pit = lt.iterator(); pit.hasNext();)
{
platforms.add( (Platform)pit.next());
}
return SUCCESS;
}catch(Exception e){
e.printStackTrace();
sess.getTransaction().rollback();
}finally{
sess.close();
}