views:

24

answers:

1

i am working on some updation in Hibernate application. in which Struts and Spring used. we do entries of .hbm file in configration file(.cfg file). but when using spring with hibernate app we do entries in application context.xml. but i can not find configration entries in entire application. Is there any other class where we configured the .hbm files

i am doing a task define here: link text i am working on updation a application. in this many hbm files are exist. i have also create a new .hbm.xml files. now i want to configured this new .hbm file. but in entire application i can not find the configration file where all .hbm files configured.

+1  A: 

Hibernate mapping files are either declared:

Programmatically when creating a Configuration

For example:

Configuration cfg = new Configuration()
    .addResource("Item.hbm.xml")
    .addResource("Bid.hbm.xml");

In an Hibernate XML configuration file

For example:

<?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"&gt;
<hibernate-configuration>
  <session-factory name="">

    <!-- Database connection settings -->
    <property name="connection.driver_class">${jdbc.driver}</property>
    <property name="connection.url">${jdbc.url}</property>
    <property name="connection.username">${jdbc.user}</property>
    <property name="connection.password">${jdbc.password}</property>

    ...

    <mapping resource="com/acme/Foo.hbm.xml"/>
    <mapping resource="com/acme/Bar.hbm.xml"/>
    ...
  </session-factory>
</hibernate-configuration>

In a Spring XML application context definition

For example:

<beans>

  <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>
  </bean>

  <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingResources">
      <list>
        <value>product.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.HSQLDialect
      </value>
    </property>
  </bean>

</beans>

Since you're using Spring, you're very likely using the above approach.

Resources


And since you have the sources, I'm afraid you won't get any more specific help without showing more stuff (which might not be possible). Do a text search if required, things can't be hidden.

Pascal Thivent