-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Can annotations and XML mapping files be mixed?
PostPosted: Fri Aug 10, 2007 9:45 am 
Newbie

Joined: Fri Aug 10, 2007 9:40 am
Posts: 2
Is it possible to mix annotated classes with classes that have had their attributes and methods mapped via XML files (in the context of Spring2)?

I've asked this same question in the appropriate Spring Forum, but no answers have been forthcoming.

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 11:04 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't know about Spring, but in vanilla Hibernate, yes you can mix strategies provided that a given class hierarchy is either fully map in XML or annotation.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.