Forums Register Login

Hibernate + Multi User Swing App + JBoss

+Pie Number of slices to send: Send
Hi Ranchers,

I'm looking for some advice in how one would structure a hibernate driven swing application that can have multiple users, connecting to a database sat on a remote server away from the actual swing app. Currently, every instance of the application creates its own session factory and i have implemented my own handling of individual sessions in the swing app that currently seems to be *ok* for the multi user aspects. (I say *ok*, but am on the lookout for cleaner pattern for this).

Lets suppose i wanted to limit access to the database on the server, so that only local connections where allowed. Would this be feasible in an application like I describe?

Some ideas i have had include setting up a JBoss server on the server and configuring datasources through JNDI. I've also seen you can expose the actual SessionFactory as a resource through JNDI, although its not obvious to me how this would work in a remote swing app? I have no practical experience of using an application server like JBoss, so am unaware really of its power/limitations in this regard. I guess, this is the thrust of my post, what are the capabilities of such an approach?

Or perhaps other developers can share there own experiences of a similar scenario and give me some food for thought with a different approach?

Thanks for any advice

Marcus.
+Pie Number of slices to send: Send
I'm not 100% sure what your current setup looks like..so I hope none of this is way off..

From what I can gather, your Hibernate setup is being done client side? I would expose the `dao` or `service` through JNDI on JBoss. This can be tightly integrated into JBoss. The client could then access the JNDI over HTTP(S) using the HTTP Invoker.

Of course, in all this..you could just as easily expose a web-service or use something like Hessian. Either way, you've got options

I would not expose my SessionFactory because that would mean managing the sessions over the client. Managing the session (lazy load errors) is tough enough

I hope this provided at least a little bit of insight. Feel free to clarify the current way the application is being implemented.

Also..how are you trying to "limit their access" to the "database"? Couldn't you just make the user only have local priviledges in your DBMS? Clarify what local means?

Best of luck,
Avinash
+Pie Number of slices to send: Send
Personally, I would take the Swing to EJB 3 on JBoss to Back End Database architecture. Even if you didn't do it that way, definitely staying away from a two tier application is highly preferred.

Mark
+Pie Number of slices to send: Send
Hi guys,

Thanks for the replies.

Mark....what are your reasons for suggesting EJB3 over Hibernate? I don't have any real production experience with either and have simply being learning Hibernate over the last few months...my understanding is that EJB3 and Hibernate are two of the same kind of thing (in terms of being persistence models). I'II be looking into EJB3 in more detail soon once i feel i've got a real understanding of Hibernate, its advantages and limitations.

So I guess what my question is...why would EJB3 suit this kind of architecture better than Hibernate? My motivation for the post is really to try and move away from the 2-tier architecture but unsure at present how to best achieve this (or if possible to achieve this) using Hibernate in a multi user Swing application.

+Pie Number of slices to send: Send
 

Originally posted by Marcus Hathaway:
Hi guys,

Thanks for the replies.

Mark....what are your reasons for suggesting EJB3 over Hibernate? I don't have any real production experience with either and have simply being learning Hibernate over the last few months...my understanding is that EJB3 and Hibernate are two of the same kind of thing (in terms of being persistence models). I'II be looking into EJB3 in more detail soon once i feel i've got a real understanding of Hibernate, its advantages and limitations.

So I guess what my question is...why would EJB3 suit this kind of architecture better than Hibernate? My motivation for the post is really to try and move away from the 2-tier architecture but unsure at present how to best achieve this (or if possible to achieve this) using Hibernate in a multi user Swing application.



I am not suggesting EJB3 over Hibernate because you can't say such a thing, it doesn't make sense.

JPA is part of the EJB3 spec, so if you use Hibernate, Hibernate is an implementation of JPA. You can choose to use Hibernate specific stuff that goes above and beyond JPA, you can also choose to use Hibernate and not use any of the JPA spec classes. You can also choose to use JPA with a different implementation than Hibernate's implementation. You could choose Toplink for instance and use their JPA implementation. But you cannot say I choose EJB3 over Hibernate or Hibernate over EJB3. Basically I personally choose to use Hibernates implementation of JPA.

Also, I work for JBoss, so Hibernate is one of our "products", but that doesn't mean that I choose Hibernate because of that, I used Hibernate well before I joined JBoss.
+Pie Number of slices to send: Send
If you do choose to stay with a two tier Rich UI application, then I actually recommend Visual Basic 6 for such an application, that would be the fastest way to write such an application.

Mark
+Pie Number of slices to send: Send
Hi Mark,

Thanks for the replies but i'm not sure we're on the same issue anymore. You've completey lost me suggesting Visual Basic.

I want to move AWAY from a 2-tier architecture but unsure where Hibernate should be "placed" in the application. Currently each client app configures its own Session Factory locally, connecting to a remote database. Reading around on the internet it seems many people have similar issues with multi user swing apps and essentially the handling of sessions, i guess i was seeing if anybody had any experience. I don't want to get into any kind of debate over EJB3 or Hibernate....my motivation is simply to try and learn a bit more about Hibernate and the best way to use it. My reading around on the subject also points me towards using a JBoss AS with Hibernate....i'd like to know why, and what advantages this will give me in this kind of setup. For instance, will i be able to only have to create one session factory per schema that multi users can pull a Session off etc? I'm really just after other peoples experience in how they have structured a similar app in a production envirionment. Someone may say its crazy to try and use Hibernate in such an architecture....i'm just after opinions and experiences really.

From your orginal post it sounded like you'd prefer to use EJB3 but without an explanation of why.

Personally, I would take the Swing to EJB 3 on JBoss to Back End Database architecture.

Not knowing EJB3 in any detail, i just wondered why you'd favour this approach.
[ October 12, 2007: Message edited by: Marcus Hathaway ]
+Pie Number of slices to send: Send
"Currently each client app configures its own Session Factory locally, connecting to a remote database."

Which is two tier.

Anyway, I wasn't arguing, because there can't be an argument over Hibernate or EJB3. It really is like arguing whether you want to either eat an Apple, or eat an Apple. Yeah the too Apples might not be the exact same size, or it could have different colors, but they are both Apples.

With a three tier architecture, yes you will only have one SessionFactory. With a three tier architecture and it you choose EJB3 Session Beans, then transactions and pooling and other great stuff you won't have to develop yourself.

That is the approach I used Swing front end, JBoss AS/EJB/Hibernate on the middle tier, and a database on the backend as Tech Lead at Gateway computers.

Mark
+Pie Number of slices to send: Send
 


"Currently each client app configures its own Session Factory locally, connecting to a remote database."

Which is two tier.



Absolutely correct....this is the motivation for the post to try and get some ideas on how i can move away from this USING hibernate.

I'm definatly going to start exploring and having a play with EJB3, so thanks for your comments. However, has anybody any suggestions for trying to achieve a n-tier architecture with a rich client using Hibernate? Am i flogging a dead horse with this
+Pie Number of slices to send: Send
 

Originally posted by Marcus Hathaway:


Absolutely correct....this is the motivation for the post to try and get some ideas on how i can move away from this USING hibernate.

I'm definatly going to start exploring and having a play with EJB3, so thanks for your comments. However, has anybody any suggestions for trying to achieve a n-tier architecture with a rich client using Hibernate? Am i flogging a dead horse with this



Yes, that is what I suggested it is an n-tier architecture with Swing.

Another option for you if you choose not to use EJB3/Hibernate is Spring/Hibernate

Mark
+Pie Number of slices to send: Send
Thanks Mark...i think the penny is finally starting to drop in what you are trying to say. I will investigate both Spring & EJB3, so i guess i've learnt from this post that i need something else (be it EJB3/Spring/whatever) to compliment Hibernate in achieving my goals.

Thanks for the comments.
+Pie Number of slices to send: Send
Yes, basically Hibernate isn't a tier in n-tier as more a layer in the architecture.

An ORM layer to help with the OO to Database mismatch issues.

Mark
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2925 times.
Similar Threads
What does using JAAS buy me?
Numerous questions on JNDI
InitialContext - don't understand how to set this from an app not hosted by appserver
Authenticating Users
EJB3 persistence unit setup in JBoss
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:45:43.