I have created a Har and depoly with a ear succesfully according to the Jboss 
doc. http://docs.jboss.org/jbossas/jboss4guide/r2/html/ch13.html

Now, I would like to call Hibernate in servlet and do some saveorupdate ,but I 
failed.

I tried this code

InitialContext ctx      = new InitialContext();
SessionFactory factory  = (SessionFactory)
                          
ctx.lookup("java:/hibernate/CaveatEmptorSessionFactory");
Session        hsession = factory.openSession();
hsession.saveOrupdate(whatever. . . .. . )

hession.close();


But nothing is saved to database and no exception is throw..


Then , I turned into this...

anonymous wrote : 
  |  The getSession method returns a Hibernate session that is linked to the 
current JTA transaction. Naturally this requires that a JTA transaction exist 
prior to the call. The following code illustrates the use of getSession. 
  | 
  | Session hsession = 
HibernateContext.getSession("java:/hibernate/CaveatEmptorSessionFactory");
  | 

But then I failed and a exception say Icannot start a transaction outside the 
bind of JTA transaction .

So How do I use the method anonymous wrote : Session hsession = 
HibernateContext.getSession ?

Is it true that I should create a session bean and call the above line in a 
session bean metod?

If yes, should I set the transaction-type to  in the deployment descrptor or 
something else?
Also, do I need those session.close() or transaction.begin() 
transaction.commit() code?



View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3867642#3867642

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3867642


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to