find the hibernate.cfg.xml example file.


General J2EE: find the hibernate.cfg.xml example file.

  1. find the hibernate.cfg.xml example file. (5 messages)

    I am using the hibernate2.0 under the websphere4 .
    Now I have using the config file ot create connection. the success is jdbc type.but I found the manual of hibernate give a hibernate.cfg.xml to configuration the engine. and the fils can appoint the mapping I hope use the method to config files. but I don't konw how to config the JNDI connection .So I hope find a example file.
    hibernate+websphere. please give me some example or docs
  2. Do you need JNDI?[ Go to top ]

    If not, then just leave off the "name" attribute in the session-factory element. Then nest your JDBC parameters (URL, username, etc.) as property elements inside the session-factory. It's just the the example in the docs, only with the JDBC properties instead of the JNDI properties.

    If you want to use JNDI, then just follow the example. You'll need to set up a JNDI name first, though.
  3. Do you need JNDI?[ Go to top ]

    hi, this is my cfg file
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        <!-- a SessionFactory instance listed as /jndi/name -->
    hibernate.connection.datasource datasource JNDI name
    hibernate.jndi.url URL of the JNDI provider (optional)
    hibernate.jndi.class class of the JNDI InitialContextFactory (optional)
    hibernate.jndi.xxxx pass the property xxxx to the JNDI InitialContextFactory (optional)
    hibernate.connection.username database user (optional)
    hibernate.connection.password database user password (optional)
        <session-factory >
            <property name="connection.driver_class"></property>
            <property name="connection.url">jdbc:db2:suzukidb</property>
            <property name="connection.username">xxx</property>
            <property name="connection.password">xxx</property>
            <property name="show_sql">true</property>
            <property name="default_schema">xxx</property>
            <property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>
            <mapping resource="com/aof/component/domain/security/SecurityGroup.hbm.xml"/>
            <mapping resource="com/aof/component/domain/party/Party.hbm.xml"/>

    It work fine , but the I have found some mssage.
    [03.06.23 10:30:32:493 CST] 1df2711 SystemOut U 2003-06-23 10:30:32,493 INFO hiberna
    te.cfg.Configuration -> Configured SessionFactory: null
    ----------------------------------------------------^ this is ok?

    I hope you can give some jndi example.I have config my webshpere datasource provider the jndiname is jdbc/Session.please help me
    write the hibernate.cfg.xml files. and put to here .Thanks
  4. Where to put .cfg.xml[ Go to top ]

    Hi, I am using WSAD5 and Hibernate2, I do not know where to put the .cfg.xml file, because I tried to put it in every directory, they are not working at all. Do you know where to put it?

    I just have a Web Project, inside the Java Source, I have a java class (setter/getter), and a servlet to get the Hibernate session, when I call
    Configuration conf = new Configuration().configure().addClass(net.sf.hibernate.examples.quickstart.Cat.class);

    it always gives me an error message saying that "
    3100cb4a Configuration I net.sf.hibernate.cfg.Configuration Configuration resource: /hibernate.cfg.xml
    3100cb4a Configuration W net.sf.hibernate.cfg.Configuration /hibernate.cfg.xml not found
    3100cb4a WebGroup E SRVE0026E: [Servlet Error]-[/hibernate.cfg.xml not found]: net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
    at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(

    This is my cfg.xml

    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"



    <property name="hibernate.connection.driver_class"></property>
            <property name="hibernate.connection.url">jdbc:db2:JDO</property>
            <property name="hibernate.connection.username">admin</property>
            <property name="hibernate.connection.password">admin</property>
            <property name="show_sql">true</property>
            <property name="use_outer_join">true</property>
            <property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>

            <!-- Mapping files -->
            <mapping resource="Cat.hbm.xml"/>


    So could anyone help me?

    Thanks a lot!
  5. We had the 'hibernate.cfg.xml not found' problem when developing
    IBM WebSphere Portalserver portlets with struts and hibernate.

    The solution was to have the hibernate.cfg.xml in WebSphere
    Application Developer in ./JavaSources and get the hibernate
    configuration at runtime this way:

    File f=new File(servlet.getServletContext()

    Configuration c = new Configuration().configure(f);

    This is portable from WSAD to WPS

  6. where servlet initialization. Can you post the code.