title: Hibernate: mix annotated classes and classic hbm.cfg.xml
body: <p><strong>someone explain the below (can and cannot) with a example?</strong></p>
  
  <p>Hibernate docs (latest)</p>
  
  <blockquote>
    <p>You can mix annotated persistent classes and classic hbm.cfg.xml declarations with the same SessionFactory. You can however not declare a class several times (whether annotated or through hbm.xml). You cannot mix configuration strategies (hbm vs annotations) in an entity hierarchy either.</p>
  </blockquote>
  
  <p><em>Can we do this? property <strong>annotatedClasses</strong> and <strong>mappingResources</em></strong></p>
  
  <pre><code>&lt;beans:bean id="hibernateSessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;beans:property name="dataSource" ref="dataSource" /&gt;
      &lt;beans:property name="annotatedClasses"&gt;
          &lt;beans:list&gt;
              &lt;beans:value&gt;com.dev.spring.model.Person&lt;/beans:value&gt;
          &lt;/beans:list&gt;
      &lt;/beans:property&gt;
  &lt;beans:property name="mappingResources"&gt;
  &lt;beans:list&gt;
      &lt;value&gt;
          com/hibernate/abc.xml&lt;/value&gt;
  &lt;/beans:list&gt; 
  </code></pre>
  
  <p></p>