Announcement Announcement Module
Collapse
No announcement yet.
Mixing annotation with XML mapping? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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...

    Code:
        <!-- Hibernate config -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource">
                <ref bean="dataSource" />
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                </props>
            </property>
            <property name="mappingDirectoryLocations">
                <list>
                    <value>classpath:/com/mcilink/ncs/acl/model</value>
                </list>
            </property>
        </bean>
    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.

    -David
Working...
X