-->
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.  [ 7 posts ] 
Author Message
 Post subject: Porting nonremote HibernateSession to remote EntityManager
PostPosted: Thu Jul 13, 2006 11:22 pm 
Newbie

Joined: Thu Jul 13, 2006 11:57 am
Posts: 5
Hallo everyone,

I am using JBossEJB2/Hibernate and bounded JNDI name: "hibernate/SessionFactory" using the HAR MBean service.

If I try to lookup the above JNDI name remotely (ie from an external GUI client) it returns null (and this is what should happen because the SessionFactory is Local and there is no RemoteSessionFactory - please correct me if i am wrong). My questions are:

1. If I use the Hibernate EntityManager wrapper instead of a Hibernate Session will I get the same error?
2. By using the EntityManager wrapper it means that I have to convert all my Hibernate persistence objects to EJB3 Entity Classes with annotations?
3 Can the EntityManager work with old fashioned hbm.xmls and configurations in the backend?
4 Do I have any other options for making the SessionFactory work both remotely (in the client side) and locally on the server side?

thanks in advance,
george


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 3:25 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Quote:
If I try to lookup the above JNDI name remotely (ie from an external GUI client) it returns null

Null? Or a NamingException?


Answers to some of your questions:

1. If I use the Hibernate EntityManager wrapper instead of a Hibernate Session will I get the same error?

Probably. See #4.

2. By using the EntityManager wrapper it means that I have to convert all my Hibernate persistence objects to EJB3 Entity Classes with annotations?

No. Answer to #3 does the trick.

3 Can the EntityManager work with old fashioned hbm.xmls and configurations in the backend?

Yes.

4 Do I have any other options for making the SessionFactory work both remotely (in the client side) and locally on the server side?

I don't think that is the way it is meant to be used.
Certainly I haven't seen such kind of usage yet.
Classes (SF, Session, ...) are serializable, but that's JNDI requirament + passivation + ...
Consider security, transactions management (what if it is CMT), database connectivity, cache usage (transactional jboss tree cache), ...

Rgds, Ales


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 4:50 am 
Newbie

Joined: Thu Jul 13, 2006 11:57 am
Posts: 5
Hi Ales,

Thanks for the quick reply.

I am quite new to EJB 3 but in EJB 2 I could easily expose my EntityBeans via a Remote Home/Interface, and have distributed transactions. Unfortunatelly I am not quite sure what happened with CMR.

So what you 're saying now is that Entity Classes are no longer exposed remotely, or that the hibernate's EntityManager is not that clever enough to support remote Entity class calls?

regards,

george


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 5:24 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Quote:
So what you 're saying now is that Entity Classes are no longer exposed remotely, or that the hibernate's EntityManager is not that clever enough to support remote Entity class calls?


Remote entity class calls?
Wasn't this where anti-pattern DO came into place?

Or do you mean Session beans - SLSB and SFSB?

How were you doing Hibernate before?
Those are plain POJOs - only thing that keeps them wired is Serialzable or Extrenalizable interface.

Read some EJB3 documentation / examples:
- http://www.oreilly.com/catalog/entjbeans5/
- http://www.jboss.com/docs/trailblazer
- http://jboss.com/products/ejb3
And some Hibernate literature: 'Hibernate in Action'


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 6:21 am 
Newbie

Joined: Thu Jul 13, 2006 11:57 am
Posts: 5
Excuse my englsh, by saying entity class calls I ment a remote interface for accessing EJB3 entitybeans, like what happened with EJB2 (RemoteHome, RemoteIntf)!

I know that they are plain POJOs. So your answer is that they can not be configured to work remotely due to EJB3 specs?

The situation of my problem is:
I have a Swing application that it is using Hibernate Locally to connect to a Local Embedded Database all in the same process! Unfortunatelly the database schema is huge with lots of one to many associations.

My work is to add a feature to this standalone GUI that it can make it remotely connect to a single Hibernate Server that runs on JBoss and configured via the hibernate MBean Service.

As you may understand the code for converting everything to SLSB and SFSB is huge so I want to keep the same SessionFactory - Session interface... I know that this is not the proper way but I also want to keep the local hibernate/database usage feature.

So my thought was to use Hibernate EntityManager on server side and then wrap this EntityManager/EntiManagerFactory over Hibernates Session/SessionFactory so that everything works fine. But as you say (correct me If I am wrong) this can not happen because the EntityManager
does not offer a Remote Interface, and everything should be exposed via SLSB or SFSB!

Do you have any suggestions for solving this problem appart from coding everything again to SLSBs?

thanx,
george


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 6:33 am 
Newbie

Joined: Thu Jul 13, 2006 11:57 am
Posts: 5
Excuse my englsh, by saying entity class calls I ment a remote interface for accessing EJB3 entitybeans, like what happened with EJB2 (RemoteHome, RemoteIntf)!

I know that they are plain POJOs. So your answer is that they can not be configured to work remotely due to EJB3 specs?

The situation of my problem is:
I have a Swing application that it is using Hibernate Locally to connect to a Local Embedded Database all in the same process! Unfortunatelly the database schema is huge with lots of one to many associations.

My work is to add a feature to this standalone GUI that it can make it remotely connect to a single Hibernate Server that runs on JBoss and configured via the hibernate MBean Service.

As you may understand the code for converting everything to SLSB and SFSB is huge so I want to keep the same SessionFactory - Session interface... I know that this is not the proper way but I also want to keep the local hibernate/database usage feature.

So my thought was to use Hibernate EntityManager on server side and then wrap this EntityManager/EntiManagerFactory over Hibernates Session/SessionFactory so that everything works fine. But as you say (correct me If I am wrong) this can not happen because the EntityManager
does not offer a Remote Interface, and everything should be exposed via SLSB or SFSB!

Do you have any suggestions for solving this problem appart from coding everything again to SLSBs?

thanx,
george


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 6:39 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Use the same domain object model and similar Hibernate configuration on both sides.

Then only expose those methods over SLSB that you eventually need - or make a SLSB that delegates all calls (almost the same EM methods) to injected EM. Watch for lazy initialization.


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

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.