This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes using Hibernate with Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "using Hibernate with Session Bean" Watch "using Hibernate with Session Bean" New topic
Author

using Hibernate with Session Bean

Prateek Jauhari
Greenhorn

Joined: Mar 07, 2011
Posts: 26

Hi,
I am working over a project that uses struts, hibernate and EJB.
I am using JBoss and MySQL and Netbeans IDE.

I created a JavaEE Project in Netbeans and in EJB module I have created few entity classes from database.
Now I have to create SessionBean which activates after i log into the system and then perform few task such as create and delete users.
I am confused how to use hibernate in my session bean to read and write database....

Help Me Please....!!!
I am badly stucked with this thing.....!!!



Thanks In Advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have you started by looking at the documentation? If not this is a good place to begin.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sunny Bhandari
Ranch Hand

Joined: Dec 06, 2010
Posts: 448

Moreover, you should have mentioned the EJB version you are using.

Some sample code would have of the session bean in question is also not a bad thing to share...


Java Experience
Prateek Jauhari
Greenhorn

Joined: Mar 07, 2011
Posts: 26


This is my session bean class structure......
I am using EJB 3.0
These classes are in an EJB Module....
and i am developing a web project using struts....
now I have a form... where will submit information....
now i wanna do is that this session ejb starts when the user log in and when the user create a new user then this createUser function in session bean.... write it into the database using hibernate....

I am totally confused how to sort this thing out...


is it possible to access hibernate in an EJB module


any kind of code or tutorial will help me

Thank you in advance.....!!!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


is it possible to access hibernate in an EJB module

Yes. There is nothing unusual about Hibernate - it is just another Java application.

The documentation I mentioned above is a good place to start.I'd recommend spending a little time writing a stand alone application, just so you can simplify the problem, then hook it into your EJB application.
Prateek Jauhari
Greenhorn

Joined: Mar 07, 2011
Posts: 26

Thank you Paul.....
I have been through that document and it helped.
May be some more time spending on that will work out my problem...

Just a one simple question do I have to use JPA for this job to be done...???
Sunny Bhandari
Ranch Hand

Joined: Dec 06, 2010
Posts: 448

JPA has support for using ORM frameworks like Hibernate (I mean the annotations and all)

But that is not a good reason to use JPA. There should be other reasons too like vendor neutral
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Sunny Bhandari wrote:JPA has support for using ORM frameworks like Hibernate

No, that's the other way around. Hibernate offers a JPA implementation.


[My Blog]
All roads lead to JavaRanch
Prateek Jauhari
Greenhorn

Joined: Mar 07, 2011
Posts: 26

Well I Have changed the overall logic for my application and now My problem is resolved

Thank you all for the concern
 
 
subject: using Hibernate with Session Bean
 
Similar Threads
NetBeans and MySQL
how to connect to a database in hibernate
How to access a Bean in From Separate EAR.
connection not released
How to add web module in ejb module in netbeans for stateless session bean