小段大帅 2017-03-29 14:39 采纳率: 0%
浏览 842

hibernate问题,搞了n久还是不行,求大神指点

这是错误提示

三月 29, 2017 10:33:16 下午 org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
三月 29, 2017 10:33:16 下午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.2.Final}
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml

这是配置文件

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.password">1995</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?characterEncoding=utf8&&amp;serverTimezone=UTC</property>
<!--         <property name="jdbcUrl"> jdbc:mysql://localhost:3306/hibernate?characterEncoding=utf8&amp;serverTimezone=UTC</property> -->
        <property name="hibernate.current_session_context_class">thread</property>
        <!--        是否在控制台打印sql -->
        <property name="show_sql">true</property>
        <!--        是否对sql进行格式化 -->
        <property name="format_sql">true</property>
        <!--        指定自动生成数据表的策略 -->
        <property name="hbm2ddl">update</property>
        <!--        指定关联的hbm.xml -->
        <mapping resource="entity/Users.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

  • 写回答

4条回答 默认 最新

  • 小段大帅 2017-03-29 14:36
    关注

    这是测试类

    public class TestUsers {
    @Test
    public void testSchemaExport(){
    Configuration configuration = new Configuration().configure();
    ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
    .applySettings(configuration.getProperties()).buildServiceRegistry();
    SessionFactory sf = configuration.buildSessionFactory(serviceRegistry);
    Session session = sf.openSession();
    // Transaction trans = session.beginTransaction();
    //

    // Users user = new Users("1","2","3");
    // session.save(user);
    //

    // trans.commit();
    SchemaExport export = new SchemaExport(configuration);
    export.create(true,true);
    session.close();
    sf.close();
    }
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置