Java – spring does not have an XML hibernate mapping class

In my ApplicationContext XML, this is how I map XML to POJO How do I map directories to class files without creating XML?

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionfactorybean">
<property name="mappingResources">
            <list>
                <value>com/custompackage/custom/spi/hibernate3/HibernateCurrentStep.hbm.xml</value>
                <value>com/custompackage/custom/spi/hibernate3/HibernateHistoryStep.hbm.xml</value>
                 <value>com/custompackage/custom/spi/hibernate3/HibernatecustomEntry.hbm.xml</value>
                  <value>user/custom/hibernate3/PropertySetItemImpl.hbm.xml</value>
                   <value>com/custompackage/user/provider/hibernate3/user/impl/HibernateGroupImpl.hbm.xml</value>
                   <value>com/custompackage/user/provider/hibernate3/user/impl/HibernateUserImpl.hbm.xml</value>
            </list>
        </property>


        <property name="hibernateProperties">
            .....
        </property>
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>

    </bean>

Solution

You can further simplify things through transformations

<property name="annotatedClasses">
     <list>
       <value>com.mycompany.sample.domain.Order</value>
       <value>com.mycompany.sample.domain.LineItem</value>
       ...
     </list>
 </property>

to

<property name="packagesToScan" value="com.mycompany.sample.domain" />

In your annotationsessionfactorybean, so now, com mycompany. sample. All classes annotated with @ entity in the domain package will be extracted automatically

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>