亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

java - eclipse 自動生成的hibernateDAO出現錯誤

瀏覽:90日期:2023-12-31 08:52:43

問題描述

java - eclipse 自動生成的hibernateDAO出現錯誤

DAO自動生成代碼

public class UserinfoHome { private static final Log log = LogFactory.getLog(UserinfoHome.class); private final SessionFactory sessionFactory = getSessionFactory(); protected SessionFactory getSessionFactory() {try { return (SessionFactory) new InitialContext().lookup('SessionFactory');} catch (Exception e) { log.error('Could not locate SessionFactory in JNDI', e); throw new IllegalStateException('Could not locate SessionFactory in JNDI');} } public void persist(Userinfo transientInstance) {log.debug('persisting Userinfo instance');try { sessionFactory.getCurrentSession().persist(transientInstance); log.debug('persist successful');} catch (RuntimeException re) { log.error('persist failed', re); throw re;} } public void attachDirty(Userinfo instance) {log.debug('attaching dirty Userinfo instance');try { sessionFactory.getCurrentSession().saveOrUpdate(instance); log.debug('attach successful');} catch (RuntimeException re) { log.error('attach failed', re); throw re;} } public void attachClean(Userinfo instance) {log.debug('attaching clean Userinfo instance');try { sessionFactory.getCurrentSession().lock(instance, LockMode.NONE); log.debug('attach successful');} catch (RuntimeException re) { log.error('attach failed', re); throw re;} } public void delete(Userinfo persistentInstance) {log.debug('deleting Userinfo instance');try { sessionFactory.getCurrentSession().delete(persistentInstance); log.debug('delete successful');} catch (RuntimeException re) { log.error('delete failed', re); throw re;} } public Userinfo merge(Userinfo detachedInstance) {log.debug('merging Userinfo instance');try { Userinfo result = (Userinfo) sessionFactory.getCurrentSession().merge(detachedInstance); log.debug('merge successful'); return result;} catch (RuntimeException re) { log.error('merge failed', re); throw re;} } public Userinfo findById(java.lang.Integer id) {log.debug('getting Userinfo instance with id: ' + id);try { Userinfo instance = (Userinfo) sessionFactory.getCurrentSession().get('com.po.Userinfo', id); if (instance == null) {log.debug('get successful, no instance found'); } else {log.debug('get successful, instance found'); } return instance;} catch (RuntimeException re) { log.error('get failed', re); throw re;} } public List findByExample(Userinfo instance) {log.debug('finding Userinfo instance by example');try { List results = sessionFactory.getCurrentSession().createCriteria('com.po.Userinfo') .add(Example.create(instance)).list(); log.debug('find by example successful, result size: ' + results.size()); return results;} catch (RuntimeException re) { log.error('find by example failed', re); throw re;} }}

hibernate.cfg.xml代碼

<hibernate-configuration> <session-factory ><property name='hibernate.connection.driver_class'>com.mysql.jdbc.Driver</property><property name='hibernate.connection.password'>lcy2350738</property><property name='hibernate.connection.url'>jdbc:mysql://localhost:3306/userdb</property><property name='hibernate.connection.username'>root</property><property name='hibernate.dialect'>org.hibernate.dialect.MySQLDialect</property><property name='hibernate.search.autoregister_listeners'>true</property><property name='hibernate.validator.apply_to_ddl'>false</property><mapping resource='com/po/Userinfo.hbm.xml' /> </session-factory></hibernate-configuration>

問題解答

回答1:

(SessionFactory) new InitialContext().lookup('SessionFactory')改為(SessionFactory)new Configuration().configure().buildSessionFactory()試試

標簽: java
相關文章:
主站蜘蛛池模板: 欧美黑人xxxx| 黄色免费网址在线观看 | 在线国产观看 | 日韩www视频| 视频自拍网 | 九九99热久久精品在线6手机 | 久久精品国产一区 | 黄色网页在线播放 | 欧美一级爱操视频 | 日韩视频久久 | 一区在线免费观看 | 激情伊人 | 欧美一级视频精品观看 | 国产91精品一区二区视色 | 日韩一区二区不卡 | 奇米色88欧美一区二区 | 有码视频在线 | 国产日韩欧美视频在线 | 日本免费毛片在线高清看 | 精品毛片视频 | 色网站在线免费观看 | 爱福利视频一区二区 | 色综合久久久久久久 | 欧美视频网站免费看 | 国产日韩欧美成人 | 亚洲综合精品香蕉久久网97 | 国产线视频精品免费观看视频 | 欧美黑人特大巨黑吊 | 亚洲精品自产拍在线观看 | 成人午夜免费视频 | 精品在线免费观看视频 | 久久久精品久久视频只有精品 | 三上悠亚先锋影音xfplay | 国产青青在线 | 亚洲国产日韩欧美在线a乱码 | 日韩一区二区三区在线观看 | 淫婷婷 | 欧美日韩国产亚洲一区二区三区 | 人人草人人澡 | 中文字幕 亚洲精品 第1页 | 中文字幕第一页面 |