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

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

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

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

問題描述

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

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

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 五月香婷婷| 91在线视频免费播放 | 国产a毛片清高视频 | 国产短视频精品一区二区三区 | 国产片91人成在线观看 | 一级骚片超级骚在线观看 | 99精品视频在线观看re | 国产成人禁片免费观看视频 | 香蕉视频在线网址 | 亚洲欧美国产毛片在线 | 久久精品国产99久久6动漫欧 | 日本妇丰满乱xxxxⅹ视频 | 高清一级做a爱免费视 | 欧美久久久久久久一区二区三区 | 五月婷婷色综合 | 免费jizz在在线播放国产 | 在线成人天天鲁夜啪视频 | 美女mm翘臀后进式动态图 | 91黄色片 | 色婷婷综合和线在线 | 在线黄色观看 | 国产又黄又爽又色视频影视网免费 | 一区二区三区在线 | 欧 | 992tv国产精品福利在线 | 91久久综合九色综合欧美亚洲 | 8mav福利视频在线播放 | 亚洲一区二区三区四区在线观看 | 国产美女高清片免费观看 | 国产一久久香蕉国产线看观看 | 免费精品美女久久久久久久久 | 达达兔欧美午夜国产亚洲 | 中文精品久久久久国产网站 | 片子免费在线观看 | 久久成人午夜 | 国产又色又爽又黄的网站在线一级 | 黄色一级片免费观看 | 欧美成人免费全部观看在线看 | 欧美曰韩一区二区三区 | 国产欧美日韩在线观看精品 | 国产精品拍拍拍福利在线观看 | 特黄毛片 |