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

更多QQ空间微信QQ好友腾讯朋友复制链接
您的位置:首頁/技術文章
文章詳情頁

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
相關文章:
主站蜘蛛池模板: 在线国产欧美 | 一级毛片免费高清视频 | 久久成人精品视频 | 欧美一二区视频 | 欧洲免费极品videos | 亚洲欧洲另类 | 免费特级黄毛片在线成人观看 | 久久国产精品久久久久久久久久 | xvideos亚洲 | a毛片免费视频 | 精品久久久久久国产免费了 | 久久精品99无色码中文字幕 | 另类婷婷| 热久久国产欧美一区二区精品 | 日本久久久久久中文字幕 | 亚洲欧美日韩专区一 | 日本sese| 中文字幕有码热在线视频 | 在线观看www妖精免费福利视频 | 亚洲精品91香蕉综合区 | 尤物视频在线观看入口 | 麻豆免费视频网站入口 | 国产美女久久久亚洲 | 久久黄色免费网站 | 免费爱爱视频网站 | 久久精品99无色码中文字幕 | 日韩精品亚洲一级在线观看 | 国产1区| 国产午夜精品久久久久免费视小说 | 日韩中文字幕在线观看 | yy9299国产精品视频 | 精品一久久香蕉国产二月 | 午夜精品成人毛片 | 91精品国产91久久久久久最新 | 国产一级特黄一级毛片 | 最新精品视频在线观看 | 女人精aaaa片一级毛片女女 | 国产成人免费高清激情视频 | 国产精品久久国产精品99 | 国产精品日本一区二区不卡视频 | 日韩一级黄色影片 |