title: Is it possible to still use Hibernate criteria, if changing the hbm.xml files by removing entire mapping relationships?
body: <p>I've been working on a project which is now in production mode. Now I've been told to remove the mappings completely from the <code>.hbm.xml</code> files so that I need to handle every relationships manually in the program code. It's really a big problem coz the every DB operation which I've written is in Hibernate Criteria.</p>
  
  <p>Just consider the following Criteria</p>
  
  <pre><code>Criteria criteria = getSession().createCriteria(Table1.class,"table1");
          criteria.createAlias("table1.table2", "table2")
          .createAlias("table1.table3", "table3")
          .createAlias("table3.table4", "table4")
          .createAlias("table3.table5", "table5")
          .setProjection(Projections.projectionList()
                  .add(Projections.property("id"),"id")
                  .add(Projections.property("c1"),"c1")
                  .add(Projections.property("c2"),"c2")
                  .add(Projections.property("c3"),"c3")
                  .add(Projections.property("table2.c1"),"table2.c1")
                  .add(Projections.property("table2.c2"),"table2.c2")
                  .add(Projections.property("table3.c1"),"table3.c1")
                  .add(Projections.property("table5.c1"),"table3.table5.c1"))
                  .add(Restrictions.eq("table4.c1", Constants.STATUS_ENABLED))
                  .setResultTransformer(new AliasToBeanNestedResultTransformer(Table1.class));
          return criteria.list();
  </code></pre>
  
  <p>This is the criteria which is written when all the relationships are present in .hbm.xml files. Now you can understand what will be problem I'm going to face when removing the mapping from .hbm.xml files. TBH, I've to rework entire DAO classes by removing Criteria and replacing it with HQL. Also I'll not be able to fetch the result directly as object by using HQL.</p>
  
  <p>Is it possible to only make small changes to the criteria (like defining the join between tables in the criteria itself) so that I'll get the same output even after removing the mappings from <code>.hbm.xml</code> files..?</p>