Results 1 to 6 of 6

Thread: Preliminary Hibernate3 and spring integration

  1. #1
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default 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 karaznie@cetelem.pl

    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. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    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).
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    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

  4. #4
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default

    Quote 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

  5. #5
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default

    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

  6. #6
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Artur

    Cool stuff! Thanks.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Replies: 6
    Last Post: Sep 2nd, 2005, 05:03 AM
  2. Replies: 0
    Last Post: May 20th, 2005, 02:14 PM
  3. Replies: 1
    Last Post: Apr 16th, 2005, 12:10 PM
  4. Spring and Hibernate3
    By pascal in forum Data
    Replies: 4
    Last Post: Jan 4th, 2005, 01:58 AM
  5. Replies: 1
    Last Post: Aug 12th, 2004, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •