Announcement Announcement Module
Collapse
No announcement yet.
Approving Spring for a new architecture - General Questions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Approving Spring for a new architecture - General Questions

    So I have a new architecture that is being created at my work to take an application inhouse and fully rewrite it. There will be times that we will be integrating with the old system and the new system as we migrate new functionality one piece at a time. I have reviewed Spring/Hibernate/iBATIS and given my recommendations to the team the Spring DAO module is definitely the way to go for us because of its JDBC framework and handling of Hibernate. So I have received some of the following questions regarding Spring. I would really love some help answering these as I have spent the last few days scouring the web and my documents for answers.

    1) In creating TO/DTO/VO (whatever you want to call them) from the DAO, many of the frameworks have to use some mechanism to load these objects from the configuration files that map the data. I understand that the question of reflection and performance really will depend on the ORM tool used and how that tool (Hibernate or iBATIS) accomplishes it. Since Springs mapping of data to TO/DTO/VO is simply based on creating implementations of mappers and things like that...it seems the direction would be what provides the most significant performance question. For Spring, is the question that how it handles extracting information from Spring configuration for wiring beans? Are these configuration files loaded into objects and app startup, so the creation and abstraction of data is very minimal?

    2) I love how Spring creates the exception handling. What control does this give the user as far as logging of exception capabilities and logging specific exception information? For instance, can data access exception allow use to easily determine what table/column/pk where the error occurred?

    3) Can a result from a query be cached so that if a developer wanted to create multiple different DTO/TO/VO from the same ResultSet, it would not re-execute the query?

    4) They asked about how transactions can span multiple EJBs and whether or not they have to be explicitly start/stop. I think I can answer this from the chapter on transactions in Spring in Action. It appears that transactions can be handled totally declaratively, which is great because Hibernate in Action called transactions a cross-cutting concern and this abstraction of transaction handling really allows the code not to leak into other layers. And from the "J2EE Development without EJB" transaction chapter, it really appears that it would be dependent on the BO because it would be the coordinator of calls to the DAO and possibly making multiple calls to different DAOs to accomplish a business rule that needs to be handled as a single transaction. It appears that Spring allows that functionality. Can you use the Jta Transaction Manager to put a straight JDBC and Hibernate instance into the same transaction?

    5) Is there a tally of the number of downloads for Spring and maybe if it is being used in large projects?

    6) Last but not least, besides known issues such as learning a new framework (which I don't believe to be a real reason not to use something better), are there any cons to Spring as opposed to just straight JDBC?

    I really appreciate your help in answering these questions. And also a thanks to all Spring information, which is really abudant at this time.

    jay

  • #2
    Re: Approving Spring for a new architecture - General Questi

    (1) I think you're misunderstanding the role that Spring's bean container plays in the application. The beans that you configure in Spring are not the domain/entity objects of the system. They are networks of singletons (typically) that represent business delegates, Data Access Objects (DAOs), and other "service" objects. Usually, these are initialized once at start-up and that's it. You seem to be asking about the performance of manipulating entity objects, which is more the purview of the ORM implementation (e.g. Hibernate). Spring is not an ORM tool, although it does have some features that make writing JDBC-based DAOs easier.

    (2) Spring defines a generic runtime class hierarchy for data access layer exceptions and maps ORM tool-specific exceptions to it. You can read about them in the docs. What you do with the exceptions (logging, etc.) is up to you. Spring will use them to determine when to roll back transactions, for example, but otherwise just throws them up the call stack.

    (3) Again, this is determined by the ORM tool--not Spring. Hibernate, for example, provides very good caching features.

    (4) Transactions can certainly span multiple DAOs, and Hibernate and JDBC DAOs can be mixed. Transaction boundaries can be declared in the config file or scoped programmatically. (The latter approach couples your business layer to Spring APIs, though, which is usually undesirable.) EJBs are not required, but are supported.

    (5) Don't know. Our project is pretty big.

    (6) Again, Spring is not a comprehensive ORM tool. It provides most of its value at higher layers--particularly the business logic and presentation layers. (Our organization uses Struts for the latter, though.)

    Comment


    • #3
      1) Spring's configuration is loaded in at startup. Springs DAO support is either based on classes that execute JDBC (no object mapping is done), or on a ORM tool - Hibernate, iBatis, etc...

      5) SF.net has some project stats, you can probably dig around more for extra info: http://sourceforge.net/project/stats/?group_id=73357

      6) I can't think of any. Your project(s) may differ.

      Comment


      • #4
        3) Can a result from a query be cached so that if a developer wanted to create multiple different DTO/TO/VO from the same ResultSet, it would not re-execute the query?
        I use Spring JDBC rather than an ORM tool, so I do my own caching using ehCache.

        I cache query results using the query criteria command object as the key. The command class has appropriate equals() and hashcode() methods based on the search criteria fields.

        ehCache was simple to learn and set up, and seems to work well.

        Comment


        • #5
          For Spring, is the question that how it handles extracting information from Spring configuration for wiring beans? Are these configuration files loaded into objects and app startup, so the creation and abstraction of data is very minimal?
          Yes. The performance overhead of reflection at runtime is a non-issue. It typically happens before the app starts up.
          Can you use the Jta Transaction Manager to put a straight JDBC and Hibernate instance into the same transaction?
          Yes, the app server will manage the transaction in this case. You can also use HibernateTransactionManager with Spring to achieve the same thing in a web container or standalone application or integration test with a JTA implementation.

          2) I love how Spring creates the exception handling. What control does this give the user as far as logging of exception capabilities and logging specific exception information? For instance, can data access exception allow use to easily determine what table/column/pk where the error occurred?
          Depends on how well the JDBC driver reports errors. Spring always keeps the stack trace and translates to the most specific exception possible. There are several ways to customize the translation if required.


          5) Is there a tally of the number of downloads for Spring and maybe if it is being used in large projects?
          SourceForge currently shows about 145,000 downloads, but it's at least 6 weeks out of date. Downloads run at well over 10K/month these days off SourceForge, and there are also other places to download Spring also.

          At the recent ServerSide Java Symposium, Spring was clearly among the top 2-3 technologies attendees were interested in, gauged by attendance at sessions, discussions etc.

          There are many large projects using Spring, including an online banking service and effective "standardization" on Spring of a large global fund manager. Unfortunately the most interesting projects are not publically referenceable, as with most technologies used in sectors like banking and finance

          6) Last but not least, besides known issues such as learning a new framework (which I don't believe to be a real reason not to use something better), are there any cons to Spring as opposed to just straight JDBC?
          I don't believe that Spring adds more to learn in total, since you don't need to deal with a lot of the complexity around JDBC resource management etc. Yet you still deal with JDBC objects such as ResultSet and PreparedStatement, so your knowledge of them, and SQL, will remain relevant.

          Coding straight JDBC ought to be a sacking offense IMO. It's too error-prone and verbose. If you don't use Spring JDBC, use another JDBC abstraction or write your own. Don't go near try/catch/finally hell. But I think the Spring abstraction is far more sophisticated than any alternative--and, of course, integrated with Spring's ORM integrations.

          Comment


          • #6
            Thank you all very much for your response. This is exactly the type of information I was looking for. I am very new to Spring but am thoroughly enjoying Spring in Action and the Spring Docs...great framework!!!

            Comment

            Working...
            X