-->
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.  [ 11 posts ] 
Author Message
 Post subject: Servler or session EJB?
PostPosted: Wed Oct 15, 2003 9:16 am 
Beginner
Beginner

Joined: Sun Oct 12, 2003 2:14 pm
Posts: 25
Location: Zagreb, Croatia
What is better approach for web site, to use Hibernate inside servlets or to use Hibernate inside session EJB? Is there one important reason why something should be done or is there some serious performance problem?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 9:18 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What is better to go shopping, a buggy or a truck? Please specify "website".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Web site with db
PostPosted: Wed Oct 15, 2003 9:21 am 
Beginner
Beginner

Joined: Sun Oct 12, 2003 2:14 pm
Posts: 25
Location: Zagreb, Croatia
Web site will be build around RDBMS, no static pages, with security, roles, about 30000 "transaction" per month.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 9:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Do you know what EJB is? Do you know what Servlets are? It's certainly better to decide for an architecture based on these questions, rather than only on Hibernate. Hibernate is flexible in any environment.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 9:57 am 
Beginner
Beginner

Joined: Sun Oct 12, 2003 2:14 pm
Posts: 25
Location: Zagreb, Croatia
I am familiar with EJB and only wrote hello world in servlet, client was plain Java Swing application. So far, I didn't use any Object-Relational mapping tool and it sounds like with Hibernate you can have functionality in servlet like you have with EJBs. Another issue is application server itself.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 4:54 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 7:21 am
Posts: 27
Location: Sweden
My view on the whole thing:

- Session EJBs is a means to make resusable application logic that can be called through a network. That's the holy grail of software resue, sort of - f.eg, design a method that returns a list of all customers, and place it in a (session) EJB on a server. In the future, whenever you need to retrieve a list of all customers, just call that method on that server, be it from a SWING GUI, another application server, a handheld device, etc. Is one of your app servers "getting full"? No problem - just add another server in the network and continue. Reusability, reusability, reusability.

- I look at Hibernate as a way to achieve DBMS independence that would be hard to achieve if I had to code the SQL manually. All my application logic is implemented as SLSB (Stateless Session Beans) methods, and can be seen as DBMS independent stored procedures, really. Does customer X run Oracle? No problem - just set the Hibernate dialect to Oracle. Does he/she run DB2? SQLServer? Postgres? Change one line in the config, and you're done. THAT's the strength of Hibernate. Oh, and it's 100000 times easier to use and much, much, more performant that CMP Entity Beans (the only alternative if you want the same functionality).

In short: if you don't mind having to recode the application logic as soon as you add a new UI, go for servlet-only. On the other hand, if you think it's possible that you in the future may need to add interfaces for "thick clients" or handhelds (or think that you could have use for that fancy dooFoo() method in some other app), go for SLSB Session Beans.

My


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 7:17 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
carniz wrote:
My view on the whole thing:


In short: if you don't mind having to recode the application logic as soon as you add a new UI, go for servlet-only. On the other hand, if you think it's possible that you in the future may need to add interfaces for "thick clients" or handhelds (or think that you could have use for that fancy dooFoo() method in some other app), go for SLSB Session Beans.

My €0.02.


I do not think it is meaningfull to use SLSB for future, it will be "evil legacy" in the futures buzz words, do solution for today and refactor it later.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 8:03 am 
Beginner
Beginner

Joined: Sun Oct 12, 2003 2:14 pm
Posts: 25
Location: Zagreb, Croatia
There is one more thing, you should split user interface and business logic, which mean that you can use servlets and EJBs for business logic and we are again on beginning.... :-)[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 4:06 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 7:21 am
Posts: 27
Location: Sweden
hbartolin wrote:
There is one more thing, you should split user interface and business logic, which mean that you can use servlets and EJBs for business logic and we are again on beginning.... :-)
[/quote]

And how are you planning to use the business logic implemented in servlets from a Swing GUI..? Using SOAP? Of course, that's one way..but different SOAP implementations vary, so I wouldn't trust that technique yet..

Logic is one thing, presentation is another - that's why I go for SLSBs for the logic part.


Top
 Profile  
 
 Post subject: No Session during call "one-to-many" from remote c
PostPosted: Tue Nov 11, 2003 4:43 am 
Newbie

Joined: Tue Oct 28, 2003 3:48 am
Posts: 8
Location: LECOTAD
carniz wrote:
hbartolin wrote:
There is one more thing, you should split user interface and business logic, which mean that you can use servlets and EJBs for business logic and we are again on beginning.... :-)


And how are you planning to use the business logic implemented in servlets from a Swing GUI..? Using SOAP? Of course, that's one way..but different SOAP implementations vary, so I wouldn't trust that technique yet..

Logic is one thing, presentation is another - that's why I go for SLSBs for the logic part.[/quote]

Hi all,
I agree with carnitz,
logic part = SLSBs for J2EE
for standart web app. U do not need SB.

one ? more. Wenn I call SLSB throw servlet to jsp it`s going fine,
but wenn I have client which call SLSB`s I take some strange
result.
Wenn I call any primitive type like int,String etc. it`s working good.
Wenn I call hibernate object then come exception no Session exist.

Guys, How do you hold object in user session???
How do U hold hibernate collection in session???


Top
 Profile  
 
 Post subject: Re: No Session during call "one-to-many" from remo
PostPosted: Tue Nov 11, 2003 4:04 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 7:21 am
Posts: 27
Location: Sweden
barbar wrote:
one ? more. Wenn I call SLSB throw servlet to jsp it`s going fine,
but wenn I have client which call SLSB`s I take some strange
result.
Wenn I call any primitive type like int,String etc. it`s working good.
Wenn I call hibernate object then come exception no Session exist.

Guys, How do you hold object in user session???
How do U hold hibernate collection in session???


This sounds like a lazy loading exception, which implies that you haven't grasped the concept of lazy loading. Either set lazy="false" for your collections of child objects, or make a separate initialization every time you need access to a child. (Hope I make sense here)

Read the docs for more info.

- Mikael


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.