Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

struts - hibernate doubt

Ads

 
 

Share on Google+Share on Google+

David
struts - hibernate doubt
0 Answer(s)      5 years and 5 months ago
Posted in : Hibernate

Hello.

I'm developing a web application using Struts 1.0 and Hibernate (I'm a beginner). I've been reading your web and I've seen that in the Struts Action methods you use an Hibernate Plugin in this way:

public ActionForward myMethod (.......){ ServletContext context = request.getSession().getServletContext(); SessionFactory _factory = (SessionFactory);
context.getAttribute(HibernatePlugIn.SESSIONFACTORYKEY); Session session = _factory.openSession(); Transaction tx = session.beginTransaction(); //... do session stuff tx.commit(); session.flush(); session.close(); ...

What is the difference between doing this and this other?

public ActionForward myMethod (.......){

    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
       Transaction tx = session.beginTransaction();
        //... do session stuff 
        tx.commit();
      .....

Some questions: 1.- What is the best option? 2.- I've read that it's not necessary to close Hibernate session nor flush the session if you use .getCurrentSession(). Is it true?

Thanks in advance.

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
doubt in struts - Struts
doubt in struts   i don't understand the concept on Resource bundle in struts can u please help me out
Doubt in struts - Struts
Doubt in struts  I am new to Struts, Can anybody say how to retrieve data from database and display it in jsp. Some said to use beans but i dont know how to do. Please help me in this regard. It will be helpful, if explained
Advertisements
I have a doubt regarding action - Struts
I have a doubt regarding action   hi, I have doubt regarding struts,I got response through jsp and once again it redirecting to action..., Please check Action Mapping in the struts-config.xml. If you have any problem
doubt this
doubt this  what is the use of "this" and "super" keyword
DOUBT ?
DOUBT ?  in c++ member function of a class must be public
Doubt
Doubt  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details
Doubt
User request form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
How to load page  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
Submit and process form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt
load next page after submitting  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
doubt regarding JSF
doubt regarding JSF  Hi, pls explain what is difference between struts &JSF? pls explain what is difference between SPRING &JSF
Doubt Regarding Charts
Doubt Regarding Charts  Hi, Can you please help me out by answering "hoe to include charts in core java code and struts code" thanks in advance, Swaroop Eswara   Please visit the following link: Jfreechart
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try... think i am able to tell u what i want to and u have got whats my doubt. plz give
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
java beginners doubt!
java beginners doubt!  How to write clone()in java strings
String doubt replace function
String doubt replace function  What is the output and why of below : String s1 = "Hello"; if(s1.replace('H','H')== "Hello") System.out.println("yes"); else System.out.println("No"); if(s1.replace("H", "H")== "Hello
"Doubt on Swing" - Java Beginners
"Doubt on Swing"  Hi Friend.... Thanks for ur goog Response.. i need to create a GUI Like... pic1.gif RadioButton pic2.gif RadioButton Pic3.gif RadioButton If we have select d appropriate radio
Doubt on Segmentation - Java Beginners
Doubt on Segmentation  Hi .. ImageProcessing.. How to segment the each and every characters from the bitmap image Consider for an example bitmap1.bmp: Visuallc++ text is on bitmap1.bmp..How to extract those from image
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi, I successfully executed the bar chart in normal java application. But I want the Bar Chart to be executed in web application(jsp). So,please help me out in how to connect the normal
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi in the http://www.roseindia.net/chartgraphs/barchart-jsppage.shtml of the code (new StandardEntityCollection()); final File file1 = new File("../webapps/jspchart/web/barchart.png
DOubt in Mysql connections
DOubt in Mysql connections  i have some problem regarding data base connections, i have created a hostname, username and password in filezilla server but after i give those names also it is showing error like this: mysql
Version of com.martiansoftware>hope-and-doubt dependency
List of Version of com.martiansoftware>hope-and-doubt dependency
Version of com.martiansoftware>hope-and-doubt dependency
List of Version of com.martiansoftware>hope-and-doubt dependency
Struts
Struts   How to retrive data from database by using Struts