-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate3 in n-tier architecture.
PostPosted: Mon Jun 06, 2005 7:00 am 
Newbie

Joined: Wed Aug 18, 2004 9:45 am
Posts: 9
Location: Warsaw, Poland
Hi,
I'm quite confused how Hibernate3 works in n-tier architecture.

Look at this real system example.

I have n-tier system. It's really quite big architecture with about 25 applications - ears. Some of this application uses Hibernate, some do not.

Let's considered application that is responsible for importing and serving data. It uses MDBs and Hibernate3 bulk operations (hundred of thousands of records) for importing data. One of application's functionality is to provide data reference and dictionaries services through EJBs.
This layer also uses Hibernate3 and CriteriaAPI to access database. It uses intensively lazy initialization either.
The next layer (applications) are services with a specific business logic. These are EJBs too, but they do not use Hibernate as a DAO.
As the result they receive ClassNotFoundException. Firstly the problem was with collections - implementation was Hibernate-specific. Secondly it appears that some hibernate classes are missing during deserialization - I'm quite sure that it is lazy initialization proxy classes.

How can I build appliaction using Hibernate3 and avoid dependency on this framework on other, not database-related tiers ? I can of course build DTO pattern around Hibernate and repack all of models in new REAL POJO models, but maybe Hibernate provides some functionalities out-of-the-box.

This code comes from http://forum.hibernate.org/viewtopic.php?t=942572, but it looks like my proxy classes do not implements HibernateProxy interface. Moreover this solution is not recommended by Hibernate Team.

Code:
public class ProxyConverter {

   public static Object convert(Object object)
   {
      if (object instanceof HibernateProxy) {
         HibernateProxy proxy = (HibernateProxy) object;
         LazyInitializer li = proxy.getHibernateLazyInitializer();
         return li.getImplementation();
      }
      else {
         return object;
      }     
   }
}



Thanks for any solution...

_________________
Tom Kucharski


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.