Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate struts - hibernate doubt
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


David
struts - hibernate doubt
0 Answer(s)      2 years and 8 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.


Advertisement
View Answers

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
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 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
java beginners doubt!
java beginners doubt!  How to write clone()in java strings
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
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 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
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 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 about Xstream Converter
Doubt about Xstream Converter  Hi, I am using the Xstream freamwork to read a lot of files in a batch operation. I use a custom converter Xstream to read some properties of my Xml file, but when I changed my application
doubt about JMS selector
doubt about JMS selector  Hi! , i have a little problem with message selector in JMS api. I'am try develop a request and response with JMS queue, but I didn├?┬┤t get success. in my case, i send a message to server, server
doubt about JMS selector
doubt about JMS selector  Hi! , i have a little problem with message selector in JMS api. I'am try develop a request and response with JMS queue, but I didn├?┬┤t get success. I use this reference site like guide. in my
Advertisements
 

 

 

DMCA.com