Question « Transaction « JPA Q&A





1. Hibernate Transaction question    stackoverflow.com

I'm using Hibernate with a JTAFactory - in my case: jBossJTA - I've configured my hibernate.xml with the current JTA, now maybe I'm doing something wrong, my dao code looks like ...

2. Question about concurrency with jpa 1.0 transactions    stackoverflow.com

Currently we're creating a single EntityManager per request in our web app. We're wanting to create a transaction at the beginning of the request and close it at the end to ...

3. Basic question about optimistic lock (Hibernate)    stackoverflow.com

I am new to use "optimistic locking" mechanism - I am using hibernate (in Jboss) and Container Managed Transaction (CMT). I want to handle the scenario when, between my entity-read and ...

4. hibernate transaction questions    coderanch.com

Hi, I have 2 questions about hibernate transactions -- 1. if I write code like try { session.beginTransaction // my database operation codes ... line 1 // my database codes .. line 2 // my database codes .. line 3 } catch(HibernateException e) { // transaction rollback } finally { // close things } Does it mean that by doing this ...

5. Transaction settings related question    forum.hibernate.org

when one service method which has tx setting as propagation="REQUIRES_NEW" invokes another service method with the same settings, does the second method use the same session or does it create a new one(assuming the default contextual settings are used)? If not what decides whether a new session is opened or the existing one is used in the invoked method, it would ...

6. Transaction settings related question    forum.hibernate.org

when one service method which has tx setting as propagation="REQUIRES_NEW" invokes another service method with the same settings, does the second method use the same session or does it create a new one(assuming the default contextual settings are used)? If not what decides whether a new session is opened or the existing one is used in the invoked method, it would ...

7. General question about transactions commit and rollback.    forum.hibernate.org

Hi I just have a question about commit and rollback. I'm sure this is probably very database vendor dependent, but I was hopping maybe some of you have an insight... What happens if.... try { begin transaction // Do 1 // Do 2 // Do 3 <-- DB network disconnected at this point of time. // Do 4 commit transaction <-- ...

8. Transaction Question    forum.hibernate.org

Correct me if I'm wrong - I think Transaction means "unit of work" - either everything is done, or nothing. So, because SELECT does not change any data, in this example there is no difference between these 2 options. More often you will have several data changing operations, eg. UPDATE and DELETE united within a transaction.

9. Basic question related to transaction.commit    forum.hibernate.org

Hi I have a basic doubt For student and address table, following code would insert rows in both the tables MANY TO ONE MAPPING IN XML Code: This class contains student details. ...





10. Some questions on concurrency    forum.hibernate.org

Hi, My team and myself are currently getting familiar with the ORM world and we surely begin to appreciate what Hibernate has to offer. We're currently testing Hibernate for a JSP-Struts-Hibernate application (with all the proper encapsulating layers between these three components). On of the actions this application needs to accomplish is the edition of reference relational tables (which all have ...

11. basic DB question on concurrency / Hibernate    forum.hibernate.org

Hi I have following *newbie* question: I am creating a "work-task"-table which records task to be processed. The idea is that multiple users are working on these tasks and are able to "check out" a set of tasks which they want to process, e.g. the 10 last entered tasks. Thus, my table requires an id for each task, a timestamp field, ...

12. transaction question    forum.hibernate.org

I have come across some behavoir with Hibernate transactions that I do not understand. I would expect a transaction rollback to invalidate a session.save, but it do not seem to. If I do the code below: Session sess = factory.getSession(); Transaction tx = null; try { tx = s.beginTransaction(); MappedObject obj = new MappedObject(); sess.save( obj ); throw new Exception(); tx.commit(); ...

13. Question about transactions    forum.hibernate.org

I have two methods which I want to call transactionally so that if one fails then the other one fails as well. Here's an example: Code: public boolean substract(String from, int amount) { ... } public boolean add(String to, int amount) { ... } public boolean transfer(String from, String to, int amount){ ... subtract(from, amount); ...

14. Session and Transaction questions    forum.hibernate.org

I am trying to understand the basics of Hibernate transactions and the way how they should be efficiently used. My questions are as follows: 1. Is Transaction.commit() and session.connection().commit() operate on the same database connection? I am asking because I don't want use Transaction API unless it is required. 2. Does Hibernate (Session) maintain some kind of default transaction for me ...

15. Question about transactions    forum.hibernate.org

The scenario is the following: * As I save the object when the transaction is committed, it is persisted in the database. The persisted object is saved in different tables of the database. One of those tables generates an error, so the transaction fails. It should be rolled back then, but the tables remain with the data that has been saved, ...

16. Beginner question on locking    forum.hibernate.org

Hi, I'm a total newbie to hibernate and to locking as well so I read few times the manual about locking, but since I have no experience with locking I don't know how I should solve the following problem: My application uses hibernate to connect to the oracle db, and read data.. I have a status flasg which show what the ...





17. Yet Another Locking Question - not getting the serialization    forum.hibernate.org

Hi, Trying to work out exactly how the locking works with Hibernate & SQL Server. I need a transaction isolation of REPEATABLE_READ - and effectively, I am trying to do a SELECT "FOR UPDATE". Now, using raw JDBC (with my JDBC Driver, JSQL Connect) if I execute a PreparedStatement with ResultSet.CONCUR_UPDATABLE, and autoCommit=false then my SELECT statements are serialized on the ...

18. a question about "Lock"    forum.hibernate.org

Dear all, I have a question about "setLockMode" for Query some codes as following.... =================================== Transaction tx= session.beginTransaction(); Query q = session.createQuery(" from Add as addr"); q.setLockMode("addr", LockMode.UPGRADE); result = q.list(); ...... tx.commit() ...... =================================== logically, When the code "q.list()" is executed, hibernate will connect to the database(DB2) and fetch records using "select ... for update" and, all records will be ...

19. question about second level cache and transactions    forum.hibernate.org

Disclaimer: I haven't looked at the ehcache src, so I'm just speculating. Now, if you enable debug level logging for the caching system and SQL, you will see messages in the following order (using ehcache): Code: 13:18:03,582 DEBUG ReadWriteCache:106 - Invalidating: 941 13:18:03,586 DEBUG SQL:237 - update blah blah 13:18:03,746 DEBUG ReadWriteCache:227 - Updating: 941 13:18:03,749 DEBUG ReadWriteCache:243 - Updated: 941 ...

20. Question about concurrency    forum.hibernate.org

Author Message tnleeuw Post subject: Question about concurrency Posted: Wed May 19, 2004 11:48 am Newbie Joined: Wed Apr 28, 2004 6:44 am Posts: 15 Location: Amsterdam, Netherlands Hi, I have two related classes, Job and Task. Although there's no relation from Job to Task, there's a many-to-one relation from Task to Job. (IE, there's a 1-to-many relationship here ...

21. Question about transactions    forum.hibernate.org

22. another idle in transaction question    forum.hibernate.org

hibernate version: Hibernate 2.1.2 database: PostgreSQL 7.4.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 (Debian 20040422) I (think) I am having problems with transactions staying open. I want to verify that it is a problem. The symptom is that I start up my program (which runs in a servlet container) and there is always (at least) one "idle in transaction" ...

23. Storage Engine Transaction Question    forum.hibernate.org

I read somewhere that in MySQL the default storage engine is MyISAM. I heard that MyISAM does not support transactions. However, when I used my servlet that had the code for Transactions in the Quickstart like: try { Session session = HibernateUtil.currentSession(); Transaction tx= session.beginTransaction(); Cat princess = new Cat(); princess.setName("Princess"); princess.setSex('F'); princess.setWeight(7.4f); session.save(princess); tx.commit(); HibernateUtil.closeSession(); } So was this a ...

24. Transaction rollback question    forum.hibernate.org

Hello, I'm new to Hibernate so this might be a stupid question, but anyway... I'm wondering wether or not Hibernate transaction rollback affects persistent objects? Here is a scenario that illustrates my question: Say I have a fat client that obtains a User object from the database when the user logs into the tool. This User object would be kept around ...

25. Newbie question about how lock works (database works)    forum.hibernate.org

When i use locks, it locks the row until transaction ends right? Hibernate could lock reading and writing as said in documentation. Example: One reads the row and lock it , the transaction is still running. Second in other transaction(internet session) tries to read or write in the row but it is locked, 1)some error is shown at this time ?! ...

26. Session/Transaction life cycle question    forum.hibernate.org

Hi I am using Hibernate 2.1. My web application is comprised of Presentation, business and data layers. 1. The business layer has a stateless session bean which calls DAO in the data layer. 2. The DAO gets session from SessionFactory calling its openSession method. 3. DAO then begins transaction, calls session.saveOrUpdateCopy(), commits the transaction, and finally calls closeSession(). I am under ...

27. Transaction question    forum.hibernate.org

Hibernate version: 2.1.7 Hello there. My base class HibernateDAO (the ancestor for every DAO in my domain model) has this insert method: Code: public Serializable insert(Entity pojo) throws PersistenceException { Session session = HibernateUtil.getSession(); Serializable s; Transaction tx = null; ...

28. Hibernate :Concurrency Question    forum.hibernate.org

Hi All, I have been asked to check if Hibernate is suitable for our project requirement .I had gone through some document available on net about Hibernate's capabilities.I had one question regarding cocurrency though : Say , 'user1' execute a Select query and am given a reference to a 'Product' object.Will Hibernate lock this object for update(ie) will no one else ...

29. Transaction question    forum.hibernate.org

Beginner Joined: Tue Dec 21, 2004 11:53 am Posts: 42 Hibernate version: 2.1.7 Hello there! I always thought that I was doing the things right using transactions. My HibernateDAO has this pattern: Code: public void update(Entity obj) throws PersistenceException { Session session = getCurrentSession(); beginTransaction(); ...

30. Question about Transactions, Commit and Rollback    forum.hibernate.org

Hi, I am a newbie to Hibernate. Got a few doubts I need to clear up. 1) Are transactions meant to be atomic? I.e. each transaction should only be equivalent to one sql statement? 2) Say I have multiple deletions I want to do and these deletions are on different tables which have parent-child relationship. Currently I only initiate 1 transaction ...

31. Questions about hibnerate + email transactions, etc    forum.hibernate.org

Two things. 1) I'd like email to participate in transactions. So I would like to access the database with hibernate within a transaction, then do say an SMTP RCPT TO: verifying that sending email will work. Then when I do the final commit I would like to commit the DB transaction as well as send the email. Is there a nice ...

32. simple session.lock question    forum.hibernate.org

33. Question about flushing and transactions    forum.hibernate.org

Suppose code like this: Code: Session session = sessionFactory.openSession (); try { Transaction tx = session.beginTransaction (); Person p = session.load (Person.class, id); session.delete (p); session.evict (p); ... p = new Person (id); // same id as above session.save (p); tx.commit (); } catch (Exception ...

34. Hibernate transactions question    forum.hibernate.org

I have a question about the transactions in Hibernate that the documentation was not able to answer Suppose I have a code like the one given below Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Event theEvent = new Event(); theEvent.setTitle(title); theEvent.setDate(theDate); session.save(theEvent); Suppose I did NOT explicitly say session.beginTransaction() and session.getTransaction().commit(); or flush(). When would the session.save() take effect (persist to the database)? In ...

35. Question on tx.commit() and tx.rollback()    forum.hibernate.org

36. question about transactions    forum.hibernate.org

In Hibernate documentation, it clearly states that transaction.commit() automatically flush() then close()s that current session. And this also applies to UserTransaction JTA environment? Here's my code: try { // UserTransaction looked up from JNDI. // tx.begin() called. // session facade started. // currentSession retrieved from JNDI binded SessionFactory // program logic is here. // display result to View. // facade.flush() (session.flush()) ...

37. Question about Transaction Semantics    forum.hibernate.org

I'm new to hibernate, just arrived from J2EE/CMT-EntityEJBs. So far I've liked hibernate, but I'm a bit confused about transaction semantics. Apollogies in advace if this is a silly question. I have a web app, and thus using the session-per-request pattern. In this app I have to deal with non-trivial bussiness rules (validations, calculations, etc) with something like: Code: public String ...

38. Question about Hibernate Transaction    forum.hibernate.org

Dear all, I have encountered the problem that I have an MDBean that is responsible to invoke a handler to create/update the common info into the DB. However, the modification of the first MDBean instance is not viewable to the second MDBean instance. The MDBeans will be invoking a handler (in singleton) that deal with the creation/update of the common info. ...

39. Mulitple updates in a transaction; newbie question    forum.hibernate.org

Hibernate version:3.2.0.ga Code between sessionFactory.openSession() and session.close(): see below... Name and version of the database you are using: MySQL 4.1.13 The question may be related to this but I'm not sure. Problems with Session and transaction handling? Read this: http://hibernate.org/42.html I'm using Hibernate in tomcat with the JDBC transaction handling as described in the document above... Question: Is it possible to ...

40. URGENT-question on concurrency    forum.hibernate.org

Hi, I really appreciate if someone give an idea regarding an issue with multiple threads. I have 2 databases. In one database, i store all the configuration information and in the other database, that information will get copied over when the request comes in, but it should be copied only once. But the problem here is if multiple threads are running ...

42. Beginners question: why use transactions?    forum.hibernate.org

Well... as long as everything works you will often not notice a difference between using a transaction or not. If things start to go badly you will see a big difference. This is because a single operation may actually be made up of several SQL statements. If you use transactions it doesn't matter where in the sequence things start to go ...