`
itmyhome
  • 浏览: 98099 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

hibernate Configuration

 
阅读更多

Configuration是hibernate的入口,在新建一个Configuration实例的时候,hibernate会在classpath里查找hibernate.cfg.xml或者hibernate.properties文件

最常见的使用Configuration方法是

Configuration config = new Configuration().configure();


将产生一个Configuration实例并调用configure()方法

configure()方法默认会在classpath下面寻找hibernate.cfg.xml文件,如果没有找到该文件,系统会打印如下信息并抛出HibernateException异常

还可以这样使用Configuration

Session session = new Configuration().configure().buildSessionFactory().openSession();

有段时间没有写hibernate了 今天写一个小程序却出现了错误

实例化Configuration时是这样写的

Configuration config = new Configuration() 没有调用configure()方法

结果报

Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set


提示必须声明hibernate Dialect 我也照着设置了方言 可发现还是报同样的错误 郁闷了半天

查看了以前写的hibernate代码 发现没有confiture()方法

某些细节还是需要注意的......

分享到:
评论

相关推荐

    hibernate-configuration

    <hibernate-configuration> <!--com/sfhn/cim_dbms/hbm/IEC61968_Assets_AssetBasics_Asset.hbm.xml map-to EAA_Asset -->

    hibernate-configuration-3.0.dtd、hibernate-mapping-3.0.dtd

    《深入理解Hibernate配置与映射:hibernate-configuration-3.0.dtd与hibernate-mapping-3.0.dtd解析》 在Java世界里,Hibernate作为一款强大的对象关系映射(ORM)框架,极大地简化了数据库操作。而`hibernate-...

    hibernateConfiguration

    **hibernateConfiguration** 在Java开发中,Hibernate是一个强大的对象关系映射(ORM)框架,它简化了数据库操作,使得开发者可以使用Java对象来处理数据,而无需编写大量的SQL语句。`hibernateConfiguration`是指...

    hibernate小程序源码

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> ...

    Hibernate_3.6.6_CHM 文档

    org.hibernate.cfg This package defines APIs for configuring Hibernate, and classes for building the Hibernate configuration-time metamodel. org.hibernate.classic This package implements backward-...

    Hibernate开发jar包

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <!-- 必须配置 --> <property name="hibernate...

    hibernate3.6API

    org.hibernate.cfg This package defines APIs for configuring Hibernate, and classes for building the Hibernate configuration-time metamodel. org.hibernate.classic This package implements backward-...

    Hibernate_Tools_for_Eclipse插件的安装和使用

    安装完毕后,创建一个新的 Hibernate 工程,选择 File -New -Hibernate Configuration File(cfg.xml),打开创建 Hibernate 配置向导。 1. 配置 Hibernate 控制台配置,选择 Create a console configuration 复选...

    hibernate配置文件hibernate.cfg.xml的详细解释

    - `<hibernate-configuration>`: 根节点,标识这是一个Hibernate配置文件。 - `<session-factory>`: 包含所有具体的配置信息,用于创建`SessionFactory`实例。 #### 三、具体配置项详解 ##### 3.1 数据库连接配置 ...

    在Eclipse中搭建hibernate项目环境步骤

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <property name="hibernate.connection.url">jdbc:oracle...

    hibernate配置文件详解

    在 Hibernate 工作的初始阶段,这些信息通过 hibernate.cfg.xml 的 mapping 节点被加载到 Configuration 和 SessionFactory 实例中。下面是一个简单的例子: ```xml <!DOCTYPE hibernate-mapping PUBLIC "-//...

    Hibernate Tool 使用文档

    - **Standard Hibernate Configuration (<configuration>)**:配置Hibernate的基本设置。 - **Annotation-based Configuration ()**:基于注解的配置方式。 - **JPA-based configuration (<jpaconfiguration>)**...

    hibernate 重点知识原创

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="hibernate"> ...

    hibernate_esb配置

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <!-- 数据库连接信息 --> ...

    Hibernate基本配置演示

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <property name="hibernate.dialect">org.hibernate....

    hibernate要点

    ### Hibernate核心知识点..."-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <!-- 显示SQL语句,便于调试 --> ...

    Hibernate_Tools_for_eclipse_HbmTool.rar

    创建Hibernate Console Configuration向导有Main、Option、Classpath、Mappings、Common五个选项卡,如果你在工程中已经引入了JDBC驱动则,直接点击Finish完成即可,以后在完成其他配置。 完成后,你就可以在...

    Hibernate+IDEA 2018 一个hibernate程序

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <!-- 数据库连接配置 --> <property name="hibernate....

    hibernate-configuration-3.0.dtd

    hibernate-configuration-3.0.dtd 文件,配置后 映射文件就会提示

    hibernate工具类大全

    DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">`,确保配置文件的格式正确。 5. **Hibernate资料...

Global site tag (gtag.js) - Google Analytics