黄炜-HH 2013-08-14 16:00 采纳率: 0%
浏览 289
已采纳

Hibernate创建sessionFactory null

请问各位:
我在使用junit进行单元测试的时候,到实例化SessionFactory的时候不成功,控制台打印的信息如下:
2013-8-14 15:36:45 org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-8-14 15:36:45 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.9.Final}
2013-8-14 15:36:45 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
2013-8-14 15:36:45 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2013-8-14 15:36:45 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/TempPrice.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/Product.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/CurrentPrice.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/LookupCode.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/LookupType.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: [color=red]Configured SessionFactory: null[/color]

我检查过我的hibernate.cfg.xml文件和未发现错误。如下:

    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
    <property name="connection.username">POSMAN</property>
    <property name="connection.password">POSMAN</property>
    <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

    <mapping  resource="com/hanqi/po/TempPrice.hbm.xml"/>
    <mapping  resource="com/hanqi/po/Product.hbm.xml"/>
    <mapping  resource="com/hanqi/po/CurrentPrice.hbm.xml"/>
    <mapping  resource="com/hanqi/po/LookupCode.hbm.xml"/>
    <mapping  resource="com/hanqi/po/LookupType.hbm.xml"/>
</session-factory>

xxx.hbm.xml文件我也检查过未发现问题,请问会是在哪个地方出的错。

感谢!

  • 写回答

3条回答 默认 最新

  • jinbingchuan 2013-08-14 17:18
    关注

    1 代码没问题的话,请把所有的映射文件删除,看下是什么效果
    2 把配置属性修改成
    oracle.jdbc.driver.OracleDriver
    jdbc:oracle:thin:@localhost:1521:orcl
    POSMAN
    POSMAN
    官方文档时这种写法
    http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/session-configuration.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 无源定位系统的时差估计误差标准差
  • ¥15 请问这个代码哪里有问题啊
  • ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库
  • ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
  • ¥15 openpcdet自制数据集评估bev精度和3d精度相同
  • ¥15 excel 上下按钮 显示行
  • ¥20 云卓h12pro 数传问题