3 Replies Latest reply on Oct 14, 2009 5:20 PM by Arbi Sookazian

    Seam, iBATIS and Ibator

    Arbi Sookazian Master

      need to learn iBATIS for Struts/Spring/iBATIS project. thinking about refactoring hotel booking to use iBATIS (SQLMaps, etc.) for CRUD as a learning experience.  I would like to use Ibator to revengr the CRUD (similar to hbm2java in Hibernate tools).


      anybody tried this yet?

        • 1. Re: Seam, iBATIS and Ibator
          Arbi Sookazian Master
          Ibator will generate:
          
              * Java POJOs that match the table structure. This may include:
                    o a class to match the primary key of the table (if there is a primary key)
                    o a class to match the non-primary key fields of the table (except BLOB fields)
                    o a class to include the BLOB fields of a table (if the table has BLOB fields)
                    o a class to enable dynamic selects, updates, and deletes
          
                There is an inheritance relationship between these classes as appropriate. Note that Ibator may be configured to generate different types of POJO hierarchies - for example, you may choose to tell Ibator to generate a single domain object for each table if you so desire.
              * iBATIS Compatible SQL Map XML Files. Ibator generates SQL for simple CRUD functions on each table in a configuration. The generated SQL statements include:
                    o insert
                    o update by primary key
                    o update by example (using a dynamic where clause)
                    o delete by primary key
                    o delete by example (using a dynamic where clause)
                    o select by primary key
                    o select by example (using a dynamic where clause)
                    o count by example
          
                There are different variations of these statements depending on the structure of the table (for example, if the table doesn't have a primary key, then Ibator will not generate an update by primary key function).
              * DAO interface and implementation classes that make appropriate use of the above objects. The generation of DAO classes is optional. Ibator will generate DAOs of the following types:
                    o DAOs that conform to the Spring framework
                    o DAOs that only use the iBATIS SQL mapping API. These DAOs can be generated in two varieties: supplying the SqlMapClient through either constructor or setter injection.
                    o DAOs that conform to the iBATIS DAO Framework (an optional part of iBATIS, this framework is now deprecated and we suggest that you use the Spring framework instead)
          



          Note that this may involve integration of Seam hotel booking with Spring b/c iBATIS DAO Framework is deprecated.  I am trying to keep this data tier integration as simple as possible (i.e. would rather not integrate Spring as well).  Any suggestions?

          • 2. Re: Seam, iBATIS and Ibator
            Francisco Jose Peredo Noguez Master

            Arbi Sookazian wrote on Oct 14, 2009 01:35:


            need to learn iBATIS for Struts/Spring/iBATIS project. thinking about refactoring hotel booking to use iBATIS (SQLMaps, etc.) for CRUD as a learning experience.  I would like to use Ibator to revengr the CRUD (similar to hbm2java in Hibernate tools).

            anybody tried this yet?


            Yes, I did, it works fine, but management of the code and the ibatis xml files gets a little cumbersome to deal with all those generated files... seam+spring-jdbc using Maps as DTOs feels more comfortable, one feels more in control, IBATIS generates lots of stuff that... well, the more I use it the more I feel like it is a YAGNI violation... but I guess YMMV

            • 3. Re: Seam, iBATIS and Ibator
              Arbi Sookazian Master

              I would prefer to use Hibernate but iBATIS is supposed to be preferred with legacy schemas (which is what our project is using).  We cannot easily refactor the db schema/model in our scenario...