午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

java - eclipse 自動(dòng)生成的hibernateDAO出現(xiàn)錯(cuò)誤

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

問題描述

java - eclipse 自動(dòng)生成的hibernateDAO出現(xiàn)錯(cuò)誤

DAO自動(dòng)生成代碼

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()試試

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 日韩免费观看视频 | 午夜小视频网站 | 亚洲国产高清在线 | 97国产在线视频 | 国产aⅴ| 久久国产精品视频 | 国产又粗又猛又爽又 | 四虎国产精品永久免费观看视频 | 精品免费一区 | 久草五月 | 97色综合 | 日韩成人av片 | 毛片在线看片 | 日韩中文字幕免费在线观看 | 蜜桃传媒一区二区亚洲 | 一二三不卡视频 | 欧美激情天堂 | 日韩亚洲欧美在线观看 | 美女毛片视频 | 成人av综合网 | 日本韩国欧美一区 | 日本一区二区三区精品视频 | 欧美色频 | 91美女在线| 黄色片网站免费看 | 鲁大师2在线观看免费播放高清 | 一级黄色在线 | 天堂在线免费观看视频 | av在线官网 | 特淫毛片| 亚洲三级在线视频 | 超碰夜夜 | 欧美中文字幕在线视频 | 久久久999 | 97麻豆视频 | 精品国产一区二区三区久久久蜜臀 | 一区二区三区四区免费观看 | 99色在线视频 | 日本高清黄色 | 久久永久视频 | 成人av免费看 |