Announcement Announcement Module
Collapse
No announcement yet.
Preliminary Hibernate3 and spring integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Preliminary Hibernate3 and spring integration

    Hi,

    During the weekend I implemented basic support for Hibernate3 in spring. This task was very simple, as HB3 is highly compatible with 2.0 (with some exceptions). Doing this i've found few interesting things:

    * Hibernate Exceptions are unchecked now,
    * Hibernate team changed signature of few exceptions methods from Class getPersistentClass() to String getPersistentClass. Unfortunatelly it affects exceptions in org.spring.framework.orm package (Currently i decided pass nulls instead of Classes - I must investigate why they changed this and what exactly they pass in returned value - I wonder if it has something in common with named-entities),
    * There are deprecated methods in Session (moved to org.hibernate.classic.Session) like int delete(...), seveOrUpdateCopy(...) - so I removed them from HibernateTemplate,
    * UserType was moved to org.hibernate.usertype.UserType,
    * UserType got two new methods: assemble and disassemble (like CompositeUserType) for better control over caching (affects spring Clob/Blob user types),

    Refectoring current spring code was quite simple tasks, but there are few
    minor problems. I just copied all orm.hibernate.* classes into new package orm.hibernate3. I didn't decide to add "3" suffix to hibernate classes, because I didn't find elegant way to add this suffix to classes like ClobStringType etc. Currently I didn't implement all new Session's methods (I will do this today). I didn't refactored test suite yet, but I unit test the code with all my applications and all tests passed.

    I don't know how to attach files in the forum, so if somebody is interested in - please contact me at karazni[email protected]

    ps. I wonder why there is no support for Critera, Query and SQLQuery in original HibernateTemplate. Ofcourse You can always get original Hibernate session and create Queries, but You have to get (proper) current session etc. It would be nice to have convinient methods for this in HibernateTemplate, wouldn't be?

    Artur

  • #2
    Artur,

    All the method calls on HibernateTemplate are self contained, since the Session has to be managed, and exceptions have to be mapped. So it is expected that if you need to use Criteria, Query, adn SQLQuery, you do it inside a callback block (i.e. HibernateCallback).

    The place for putting code so it doesn't get lost is in JIRA actually, as an enhancement request (alternate place is the Confluence wiki, for code that will probably not ever make it into Spring but is useful beside it).

    Comment


    • #3
      FYI, I've just added overloaded constructors that take a persistentClassName String to ObjectOptimisticLockingFailureException and ObjectRetrievalFailureException. You should be able to pass the Hibernate3 persistentClass Strings in there now, as alternative to Class objects.

      Juergen

      Comment


      • #4
        Originally posted by Juergen Hoeller
        FYI, I've just added overloaded constructors that take a persistentClassName String to ObjectOptimisticLockingFailureException and ObjectRetrievalFailureException. You should be able to pass the Hibernate3 persistentClass Strings in there now, as alternative to Class objects.
        Juergen
        Thanks - this is great!

        I just added JIRA and attached with basic hibernate3 source code support for spring sandbox. For people who are interested in http://opensource.atlassian.com/proj...browse/SPR-300

        Artur

        Comment


        • #5
          I just uploaded complete (say - more complete support for Hibrnate3-alpha into JIRA. I added new "entity-name" related methods, added test suite for new methods and all test passed.

          If You are interested in - just download, unpack into Your springframework directory and compile (don't forget about hibernate3 and antlr jars).

          Artur

          Comment


          • #6
            Artur

            Cool stuff! Thanks.

            Comment

            Working...
            X