日期:2014-05-20  浏览次数:20824 次

关于◎SuppressWarnings("Unchecked")
package   net.sf.hibernate.examples.quickstart;  
import   org.apache.commons.logging.Log;  
import   org.apache.commons.logging.LogFactory;  
import   net.sf.hibernate.*;  
import   net.sf.hibernate.cfg.*;  
◎SuppressWarnings( "Unchecked ")
public   class   HibernateUtil{  
private   static   Log  

log=LogFactory.getLog(HibernateUtil.class);  

private   static   final   SessionFactory   sessionFactory;  
static{  
try{  
sessionFactory=new   Configuration().configure().buildSessionFactory();  
}  
catch(Throwable   ex){  
log.error( "Initial   SessionFactory   creation   failed. ",ex);  
throw   new   ExceptionInInitializerError(ex);  
}  
}  
public   static   final   ThreadLocal   session=new   ThreadLocal();
◎SuppressWarnings( "Unchecked ")  
public   static   Session   currentSession()   throws   HibernateException{  
Session   s=(Session)session.get();  
if(s==null){  
s=sessionFactory.openSession();  
session.set(s);  
}  
return   s;  
}  
◎SuppressWarnings( "Unchecked ")
public   static   void   closeSession()   throws   HibernateException{  
Session   s=(Session)session.get();  
session.set(null);  
if(s!=null)  
s.close();  
}  
}  
我用了◎SuppressWarnings( "Unchecked ")这个啊   为什么编译器还报  
"使用了未经检查或不安全的操作 "


------解决方案--------------------
不用理会