Announcement Announcement Module
No announcement yet.
Mixing annotation with XML mapping? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mixing annotation with XML mapping?

    Is it possible to mix annotated classes with classes that have had their attributes and methods mapped via XML files?

    I'm working on a project that started out with XML mapping, but we want to eventually move to a fully annotated model. It's going to be a while before we can go back and do this, but I'd like to make any new classes we add annotation-based.

    In our dataAccessContext.xml file, we currently handle the Hibernate features via...

        <!-- Hibernate config -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource">
                <ref bean="dataSource" />
            <property name="hibernateProperties">
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                    <prop key="">update</prop>
            <property name="mappingDirectoryLocations">
    Since AnnotationSessionFactoryBean is a subclass of LocalSessionFactoryBean, should I be able to change the bean class to AnnotationSessionFactoryBean and have two property entries, one pointing to the mappingDirectoryLocations and the other pointing to a list of annotatedClasses?

    I've tried a number of combinations, but nothing has completely succeeded.

    Depending on what (if any answer) someone may have about the concrete ability to mix mapping types, I'll go into more detail if needed.