Search code examples
javaeclipsehibernatespringhibernate-tools

use hibernate tool with spring project


i have existing project with datasource setup with spring.xml .

the xml look like below

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

    <property name="url"
                  value="jdbc:oracle:thin:@xxx:1511:xxx"/>
        <property name="driverClassName"
                  value="oracle.jdbc.OracleDriver"/>
        <property name="username" value="xxx"/>
        <property name="password" value="xxx"/>  

    </bean>

inside eclipse, i click new ->other->hibernate-> hibernate console configuration. how to use hibernate tool inside eclipse to connect to database using setting of spring.xml file like above? or is there way to manually enter those setting in hibernate console inside eclipse to connect to database so that i can do reverse engineering on database table?


Solution

  • Install hibernate tools first:

    you can look at Hibernate Tools setup for screen shots here is a sample file which you can use as it as just entering your DB credentials

    <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      <hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.password">username</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@172.21.91.41:1521:DB</property>
        <property name="hibernate.connection.username">passWord</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
    </session-factory>
     </hibernate-configuration>
    

    create hibernate.cfg.xml file with the above text and import it while configuring hibernate tools