zoukankan      html  css  js  c++  java
  • Hibernate学习备忘

    1.关于Hibernate异常:

    org.hibernate.service.jndi.JndiException: Error parsing JNDI name
     
    刚接触Hibernate,调试一个简单的程序报告异常:
    org.hibernate.service.jndi.JndiException: Error parsing JNDI name
    去掉hibernate.cfg.xml
    <session-factory name="sessionFactory">
    中的 name属性,异常解除。
    没有明白是什么原因。
     

    2.JDBC for SQL Server的连接描述:

     <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
            <property name="hibernate.connection.url">jdbc:sqlserver://xxhxsql2008;DatabaseName=yourdatabase;SelectMethod=cursor</property>
            <property name="hibernate.connection.username">sa</property>
            <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    注意driver和url的描述
     

    3.表映射

    可以放在hibernate.cfg.xml中:
    <mapping resource="Person.hbm.xml"/>
    也可以在代码中动态指定:
    Configuration cfg = new Configuration().addResource("Person.hbm.xml").configure();
     

    4.Hibernate4中的一点变化:

    serviceRegistry = new ServiceRegistryBuilder().applySettings(
          cfg.getProperties()).buildServiceRegistry();
        sessionFactory = cfg.buildSessionFactory(serviceRegistry);
           
     
    buildSessionFactory函数新的变化。
  • 相关阅读:
    CSS揭秘三(形状)
    CSS揭秘(二背景与边框)
    js数组去重
    Iterator
    ES6数据结构set
    JS浏览器对象(BOM)
    JS 数据类型转换
    js的cookie,localStorage,sessionStorage
    (html+css)云道首页
    蓝桥杯-基础练习 01字串-C语言-5层循环法
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/3340307.html
Copyright © 2011-2022 走看看