av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

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

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

瀏覽:140日期: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
相關文章:
主站蜘蛛池模板: 日韩综合在线 | 亚洲视频一区 | 国产1区在线| 日韩成人在线观看 | jav成人av免费播放 | 国产中文一区二区三区 | 毛片免费在线 | 精品一区二区三区免费视频 | 日韩免费视频一区二区 | 日韩欧美网 | 欧美成人黄色小说 | 午夜丰满寂寞少妇精品 | 欧美不卡在线 | 欧美v免费 | 四季久久免费一区二区三区四区 | 国产精品一区二区在线播放 | 国产精品免费看 | 丝袜美腿一区 | 久久久久久高潮国产精品视 | 99久久精品国产一区二区三区 | 精品欧美一区二区三区免费观看 | 91在线看| 九九热精品视频在线观看 | 亚洲精品一区二区在线观看 | 精品日韩一区二区 | 做a网站 | 一区二区三区四区国产 | 久久久精品 | 热久久性 | 91在线电影 | 午夜网 | 欧美日韩一区在线播放 | 日韩视频―中文字幕 | 亚洲综合色网 | 亚洲欧美日韩精品久久亚洲区 | 久热免费 | 国产精品一区二区久久 | 久久久久中文字幕 | 中文字幕一区二区三区不卡 | 天天草狠狠干 | 男女又爽又黄视频 |