成人视屏在线观看-国产99精品-国产精品1区2区-欧美一级在线观看-国产一区二区日韩-色九九九

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

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

瀏覽:152日期: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
相關文章:
主站蜘蛛池模板: 99精品欧美一区二区三区美图 | 免费 欧美 自拍 在线观看 | 国产杨幂福利在线视频观看 | 国产高清视频免费最新在线 | 欧美与黑人午夜性猛交久久久 | 国产精选91热在线观看 | 最新三级网址 | 一级毛片免费在线 | 大尺度福利视频在线观看网址 | 亚洲欧美久久精品 | 国产高清久久 | 欧美丝袜xxxxx在线播放 | 午夜成人免费影院 | 不卡一区在线观看 | 国产三级黄色 | 亚洲精品成人久久 | 91色综合综合热五月激情 | 精品视频99 | 国产在线观看网址你懂得 | 2017天天爽夜夜爽精品视频 | 美女网站18 | 色在线网站免费观看 | 欧美激情视频一区二区免费 | 在线观看亚洲专区 | 三级视频网站在线观看 | 久久91亚洲精品中文字幕奶水 | 国产精品久久久久久久久久久不卡 | 久久91精品国产91久久跳舞 | 精品国产成人a在线观看 | 欧美a一片xxxx片 | 国产一区二区三区美女在线观看 | 91福利国产在线观一区二区 | 92看片淫黄大片看国产片 | 亚洲第一区在线 | 欧美xxxxx毛片| 国产亚洲一区二区手机在线观看 | 最近手机中文在线视频 | 一区二区亚洲精品 | 一级做a爰片久久毛片唾 | 国产一级视频免费 | aa国产|