`
孙健坤
  • 浏览: 42030 次
  • 性别: Icon_minigender_1
  • 来自: 长春
最近访客 更多访客>>
社区版块
存档分类
最新评论

hibernate的Configuration对象的configure()方法的作用

阅读更多

hibernate的小练习,对configurationconfigure()方法很好奇,为啥创建的对象还要执行这个方法呢。

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

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

其实不使用configure()方法也可以Configuration cfg = new Configuration();这时hibernate会在classpath下面寻找hibernate.properties文件,如果没有找到该文件,系统会打印如下信息并抛出HibernateException异常。

分享到:
评论

相关推荐

    hibernate-configuration-3.0.dtd

    hibernate-configuration-3.0.dtd,分享一下,给需要用的人。

    hibernate操作数据库笔记

    初始化Hibernate:在要使用Hibernate的类的方法中实例化Configuration对象并用Configuration对象的configure()方法将hibernate.cfg.xml中的配置加载到内存,即: Configuration config = new Configuration()....

    J2EE利用Hibernate采用B/S架构网页设计

    import org.hibernate.cfg.Configuration; /** * Configures and provides access to Hibernate sessions, tied to the * current thread of execution. Follows the Thread Local Session * pattern, see {@...

    Hibernate3使用经验

    * 注意:HQL中使用参数的方法: * 1.根据参数名称来设置参数:匹配名称; * 2.根据参数位置来设置参数:匹配位置; */ //根据参数名称来设置参数 Query query = session.createQuery("from UserManager u where u....

    根据hibernate生成表

    根据hibernate映射文件生成表 Configuration cfg = ( new Configuration()).configure(new File("src/hibernate.cfg.xml"));

    Hibernate1

    SessionFactory factory = new Configuration().configure().buildSessionFactory(); Session session = factory.openSession(); session.beginTransaction(); session.save(student); session....

    HIbernate4.3.6整合c3p0所需jar

    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService...

    自己写的Hibernate

    1 Database : use mysql5 2 Developer: MyEclipse 5 3 Liberary : J2EE1.4 + JDK1.5 ...参考前辈的经验,非用hibernate生成的,但是并不是说会比生成的好,只是学习一种代码的书写方法和其它一些东西,希望对你有帮助。

    commons-beanutils-1.7.0

    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184) at org.hibernate.cfg.Configuration.configure...

    mysql+jdbc+jsp+Hibernate3.2+tomcattomcat5.028成功测试

    sessionFactory = new Configuration().configure().buildSessionFactory(); Session session1 =sessionFactory.getCurrentSession(); session1.beginTransaction(); <br> String title="jkh" ; ...

    Hibernate5的Query接口浅析

    Configuration cfg=new Configuration().configure("hibernate.cfg.xml"); SessionFactory sf=cfg.buildSessionFactory(); Session session=sf.getCurrentSession(); Transaction tx=session.beginTransaction();

    ACCP8.0北大青鸟SSH10章上机

    Configuration configuration = new Configuration().configure(); SessionFactory sessionFactory = configuration.buildSessionFactory(); Session session = sessionFactory.openSession(); 或者通过MyEclipse...

    三大框架原理

    1.通过Configuration().configure();读取并解析hibernate.cfg.xml配置文件 2.由hibernate.cfg.xml中的读取并解析映射信息 3.通过config.buildSessionFactory();//创建SessionFactory 4.sessionFactory.openSession()...

    Hibernate 主清单文件配制的详细介绍

    Hibernate 主清单文件配制的详细介绍 1 Hiernate 清单配制文件 ...private static SessionFactory factory = new Configuration().configure().buildSessionFactory(); /** * 获得线程绑定的session * @return

    SSH的jar包.rar

    1.通过Configuration().configure();读取并解析hibernate.cfg.xml配置文件 2.由hibernate.cfg.xml中的读取并解析映射信息 3.通过config.buildSessionFactory();//创建SessionFactory 4.sessionFactory....

    spring-boot-reference.pdf

    16.2. Disabling Specific Auto-configuration Classes 17. Spring Beans and Dependency Injection 18. Using the @SpringBootApplication Annotation 19. Running Your Application 19.1. Running from an IDE ...

    jsp Hibernate入门教程第1/3页

    例如: 代码如下:HibernateTest.java ... public class HibernateTest { public static void main(String[] args) throws HibernateException { SessionFactory sessionFactory = new Configuration().configure().bui

    客户关系管理系统框架搭建(二)

    Configuration config=new Configuration(); config.configure(); SessionFactory sf=config.buildSessionFactory(); Session s=sf.openSession(); Transaction tx=s.begin...

    中小公司人事管理系统

    private static final Configuration cfg=new Configuration(); private static SessionFactory sf=null; private static Session s=null; private static final ThreadLocal<Session> sessionThread=new ...

    Manning JBoss in Action: Configuring the JBoss Application Server

    It shows how to configure the server's various component containers such as the JBoss Web Server, the EJB 3 server, and JBoss Messaging. It also provides detailed insight into configuring the various...

Global site tag (gtag.js) - Google Analytics