lock « Transaction « JPA Q&A





1. OptimisticLocking and @OneToMany(mappedBy=...) handling?    stackoverflow.com

I have an AbstractEntity class as superclass for all my entites that defines an optimistic lock column like this:

@Version
private long lockVersion;
Now I often get OptimisticLockingExceptions on entities, that are only changed ...

2. Lucene deletable files are locked    stackoverflow.com

I use to reindex MassIndexer. I got example of code from some site(can't remember where).

massIndexe.purgeAllOnStart(true) // true by default, highly recommended
.optimizeAfterPurge(true) // true is default, saves some disk space
.optimizeOnFinish(true) // true ...

3. When to explicitly exclude Optimistic Locking (Hibernate)?    stackoverflow.com

Under what circumstances would it be appropriate to explicitly exclude optimistic locking from a @OneToMany relationship via Hibernate? I have been reading a post on Hibernate which basically says any updates to ...

4. How to do optimistic locking in hibernate    stackoverflow.com

I am completely new to Hibernate and Spring and in my attempt to learn Spring, Hibernate, Maven etc I only know how to run a hello world example using all of ...

5. Hibernate locking a arraylist of items    stackoverflow.com

List <Student> st = session.createQuery ("select ids from students where a = :a")
                   ...

6. hibernate and locking    stackoverflow.com

I'm trying to exclude two reading threads from read the same record via hibernate. My SSCCE is as above, but both threads can read the object, while i was expecting that ...

7. JPA: Setting @JoinColumn(updatable = false) to avoid OptimisticLockException    stackoverflow.com

Given the following the following two entities

@Entity
public class A {
  @Version
  protected int version;

  String basicPropertey;

  // getter and setter for basicProperty
}

@Entity
public class B {
  @Version
 ...

8. Hibernate + locking    coderanch.com

The usual way to do this is to have a version property on the object, a tag in the mapping file, and a version column in the table in the database. This is incremented very time the object is updated, and hibernate can check that the version numbers match when you do an update. If they don't it will throw ...

9. hibernate locking strategies    coderanch.com

Hi All, I just wanted to check something i'm unsure about, I'm writing a multi-user swing based app with hibernate and am a little unsure when it comes to locking strategy. say for example, user Foo wants to edit a record which reflects a customers details, I envision the user clicking on a text field which at that point I want ...





10. Hibernate Optimistic Locking    coderanch.com

Can some body explain if this is the expected behaviour, My application uses 'version' for optimistic locking and following is used to specify the version property @hibernate.version column="version_id" type="long" I am reading a record for update (displayed on GUI). During this update process (before making final update call) some other process (may be external) comes along and updates the same record ...

11. Standard JPA and dead locks    coderanch.com

My app is using Struts2 + Spring + JPA (Standard). Currently the struts actions access service classes which return entities. All my service classes have Spring's @Transactional annotation on them. When more than one person uses the app lots of dead lock conflicts occur. This is really not cool. I have tried changing the isolation levels for the transaction but I ...

12. How to Obtain Lock using Hibernate Criteria API    coderanch.com

Hi All, I'm trying to use Hibernate Criteria API to obtain row locks in the Oracle Database. When I try to use the setLockMode method of the criteria API it is giving a null pointer exception in the Hibernate framework. I'm not able to figure where I'm going wrong. This is the code that I'm using to obtain the lock - ...

14. Hibernate optimistic-lock="true" not working    coderanch.com

I have made optimistic-lock="dirty" dynamic-update="true" for the entity in mapping file. And the code to test this is: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package hibernatenewappl; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import org.hibernate.EntityMode; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; /** * * */ public class ...

15. JPA Optimistic lock on Web environmnet - does not work?    coderanch.com

I used to work for a company who had own ORM solution, and used Optimistic Lock to handle concurrent updates on Java EE applications, and it worked fine. JPA has out of the box solution with @Version. Which I can not get to work. I have googled a bit, couldn't find detailed explanation or proper sample to confirm so. I don't ...

16. JPA - Optimistic Lock Violation    coderanch.com

Hello I am using JPA in a relatively simple way, but I'm running into optimistic lock violation exceptions. My understanding is that this happens when an update is performed on version_a of a record when there exists a newer version_b that has already been committed by another transaction. The odd thing is that I am doing no such thing in my ...





17. Optimistic locking and timestamps    forum.hibernate.org

I am currently developing an application using Hibernate 3.2 annotations and Oracle 10g. A requirement of the project is that all dates generated in db are derived from a function not from sysdate or systimestamp. Basically the function returns sysdate/systimestamp plus (or minus) x days - where x is a value stored in database. This is supposed to make testing easier ...

18. Optimistic locking    forum.hibernate.org

I have a model object Person that I persist with hibernate. I have a field versionNumber that has a @Version tag on it and I have a setter and getter (setVersionNumber and getVersionNumber). Optimistic concurrency control works fine and I can see that my version is incrementing properly and that concurrent changes are caught correctly. I was expecting the following to ...

19. blocking locking and transaction    forum.hibernate.org

Dear Members, I have web application which uses Hibernate for persistence. The Whole system is data centric that means lots of huge (involving millions) data operations happening at the back end (oracle). I have very strange problem. I have front end where a link click results in one row insert in a table (for example TEST_TABLE). But TEST_TABLE is locked (blocking) ...

20. locking issues    forum.hibernate.org

I have a script that runs for hours sending out large email campaigns.. I have a table called "Email" and a table called "Sent" there is a FK in sent that references the email table.. I have a large for loop, that loops thru all the contacts the email is to be sent to, it creates a new Sent entity for ...

21. Locking problem    forum.hibernate.org

I'm facing a problem i think alot of people faced it. The problem that i have a table Account and a lot of transaction done on this table update and read so i got inconsistent data problem "two transaction read the account balance the first one commit and update the balance so the second one have a wrong balance now!!" so ...

22. Issues with optimistic locking get SQLException *File in use    forum.hibernate.org

I am using hibernates implementation of JPA 1, using a Version column for optimistic locking. When reading and updating the same row from a GUI I successfully receive an optimistic locking exception. When I run concurrent threads through a webservice for the same rows I get the stack trace below.. Code: Caused by: java.sql.SQLException: [SQL0913] Row or object [TABLE NAME] in ...

23. Optimistic Locking    forum.hibernate.org

Hi all, I want to use optimistic locking to stop more than 1 user to modify the data of a screen simultaneously. On first time modify, my functionality is to change one flag of the given data and to create a new entry for modified record. I have used @Version. On modify on first screen, version of existing record is incrementing ...

24. optimistic locking issues    forum.hibernate.org

Hi all, I have asked this in the Seam forum but nobody seems to be interested. And this may as well be the correct place to post anyway. This is a Seam based web-application using Hibernate as the JPA provider. I have a database table that is updated in a highly concurrent manner. Further, the updates are done via different asynchronous ...

25. AbstractMethodError ... AbstractEntityPersister.lock    forum.hibernate.org

I would really appreciate some assistance with this problem. I have used Hibernate 1.2 in the past and this worked very well. I am trying out Hibernate 2 for the first time and having some problems. I saw a very brief answer to this in the FAQ that mentioned something about Classic VM but didn't go into any detail. Version: Hibernate ...

26. Optimistic locking    forum.hibernate.org

I am trying to use an optimistic locking strategy. So I have the following steps: 1. Load an object from DB. 2. Get its ID. 3. Send ID to the client. 4. Client sends back ID and some new data. 5. Server site gets the object from the cache by its ID without hitting DB. 6. Get the old timestamp of ...

27. Is locked    forum.hibernate.org

28. How to optimistically lock a DomainObject graph?    forum.hibernate.org

Is there a way to ensure that a DomainObject graph i.e. a Parent with a collection of children is versioned as a single unit. Hibernate seems to increment the parent version when a child is added/removed from the parent collection. However it doesn't seem to do so if a child is updated. Was there a reason this was not done? Because ...

29. Optimistic Locking and the Web    forum.hibernate.org

I'm having a complete brain lapse today and am looking for a little clarification on how to accomplish locking in our app. I believe I understand how optimistic locking works, but I'm still missing something on how to use it in a web environment. From the docs: Code: // foo is an instance loaded by a previous Session foo.setProperty("bar"); session = ...

30. Want to alter Hibernate locking implementation    forum.hibernate.org

31. How to use Optimistic Lock in Hibernate    forum.hibernate.org

Hi all I have not used neither Hibernate and optimistic lock before and after reading the programmer's guide of the Hibernate I am very interested in using it. However, I am not sure it and want to hear the advice from the experienced developers. I am using MS SQL Server and I have tried using the timestamp to implement the optimistic ...

32. About locking    forum.hibernate.org

Suppose I got 2 users... so 2 different HttpSession objects, each user loads from the db using Hibernate the same persistent object, so they both perform session.load(aClass.class, new Long(10)) then both users have different instances of the same persistent class. One user modify the firstName attribute of that instance and call session.save(firstInstanceModified) and then the other user modify lastName Attribute of ...

33. Optimistic Locking in a Webapp    forum.hibernate.org

34. Expired while locked?    forum.hibernate.org

35. Need a clarification on Optimistic Locking    forum.hibernate.org

I simply need some minor clarifications, I am not running code yet. Hope someone will oblige: First, how does the programmer indicate to Hibernate that he wants to use Optimistic Locking? I mean, at some point, Hibernate must check versions right? My understanding is that when a session is disconnected and reconnected, all objects in Session cache are automatically version verified ...

36. Optimistic locking with CRC checking    forum.hibernate.org

Has anyone implemented or thought of implementing optimistic locking with CRC checking? A quick search of the forums didn't yield anything. I have the typical case where there are a lot of legacy apps writing to the DB that no one is going to change. It seems like it'd be pretty simple to do on top of Hibernate--just a get with ...

37. Adding optimistic locking with checksums to Hibernate    forum.hibernate.org

Beginner Joined: Mon Aug 09, 2004 3:35 pm Posts: 22 Location: Minneapolis, MN, USA I'd like to add optimistic locking using checksums to Hibernate, so I was hoping to get a few of you to look over my shoulder at the rationale and proposed changes to see if I have any fundamental flaws. These are the changes I think I need ...

38. Locks and Associations    forum.hibernate.org

Hi, I believe (and someone needs to confirm), in case of "table per subclass" strategy, when an object is to be fetched with some lock on data, Hibernate will acquire lock on data in all the tables of its class hierarchy. Do locks cascade to associated objects during fetch? I tried to make out from the reference manual, but I found ...

39. cannot lock an unsaved transient instance    forum.hibernate.org

40. optimistic locking and evict    forum.hibernate.org

41. Cannot initialize proxies after lock    forum.hibernate.org

42. optimistic-lock for composite-element    forum.hibernate.org

I'm using Hibernate 3.2 and have the same issue. My composite-element maps to a table which has a VERSION_ID column for optimistic-locking purposes. I'm not clear on your reply. Are you saying, it's not possible to do with an composite-element? Does anyone have an example of how to create a mapping file for this case? Mark

43. Application Transaction using Lock    forum.hibernate.org

Hibernate version: Mapping documents: Code between sessionFactory.openSession() and session.close(): Full stack trace of any exception that occurs: Name and version of the database you are using: The generated SQL (show_sql=true): Debug level Hibernate log excerpt: Hi, I am trying to use application transaction between 2 clases and trying to insert in the second one but apparently because I did session.save in ...

44. Use of lock() in Auction example app    forum.hibernate.org

I'm not familiar with that particular example mode, but I can offer this: There are two reasons you'd use lock() on an object: 1) to upgrade it's lock to an optimistic lock for concurrency reasons, and 2) to associate an object with a Hibernate session. I suspect that this code is using session.lock(object, LockMode.NONE) as a way to associate the object ...

45. NonUniqueObjectException on reassociation with lock()    forum.hibernate.org

Author Message macrule Post subject: NonUniqueObjectException on reassociation with lock() Posted: Mon Mar 14, 2005 8:06 pm Newbie Joined: Mon Mar 14, 2005 6:58 pm Posts: 3 Hello everyone, I've been using Hibernate for half a year now and am very happy with it. But now I'm stuck with a problem that I just seem unable to solve. I'm ...

46. Lock could not be acquired after 15000 ms    forum.hibernate.org

Beginner Joined: Mon Jan 24, 2005 6:42 pm Posts: 26 I deployed test application in JBoss, Hibernate runs as a service (HAR file). Hibernate is configured to use JBoss TreeCache (v. 1.2.2). Once WAR file is deployed the first time I hit the database data comes back, however if I wait for 15 seconds or so I see Exception below. Does ...

47. a concrete optimistic locking example    forum.hibernate.org

Hi, Suppose: class Person { Long id; Long version; String name; Set categories; } class Category { Long id; Long version; String name; } Person has one-to-many association with Category, and both classes are specified to hibernate with versioning for optimistic locking. Regarding to the CRUD operations; Create and Read operations are not confusing, since "create" merely instantiate a new object ...

48. Problem with Optimistic Locking and Detecting Real Changes    forum.hibernate.org

Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message paultaylor Post subject: Problem with Optimistic Locking and Detecting Real Changes Posted: Wed May 11, 2005 11:39 am Beginner Joined: Thu Apr 21, 2005 12:15 pm Posts: 26 hi I have a problem Using Optimistic Locking ...

49. Optimistic Locking and Trigger    forum.hibernate.org

50. Optimistic Locking not working    forum.hibernate.org

java:/MySqlDS true org.hibernate.dialect.MySQLDialect false ...

51. Temporarily disable optimistic locking?    forum.hibernate.org

Hi, We have a certain background daemon which will use Lucene to index some records being updated. To prevent re-indexing records that have not been changed, the daemon will update a "lastIndexedAt" field after the record is indexed. The data record classes are applying Hibernate's optimistic version-stamp locking. This frequently causes StaleObjectException at either the daemon or the main operation server ...

52. Optimistic Locking and Legacy trigger v#=v#+1    forum.hibernate.org

org.hibernate.util.JDBCExceptionReporter SQL Error: -723, SQLState: 09000 org.hibernate.util.JDBCExceptionReporter [SQL0723] SQL trigger PTYCON_BEFORE_UPDATE_GBP101 in *N failed with SQLCODE -438 SQLSTATE 38501. org.hibernate.event.def.AbstractFlushingEventListener Could not synchronize database state with session AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener TRAS0014I: The following exception was logged org.hibernate.exception.GenericJDBCException: could not insert collection: [be.gfdi.ent.party.common.model.Employer.contactInfos#5000000000005] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)

53. problem with optimistic lock    forum.hibernate.org

Author Message icdevelop Post subject: problem with optimistic lock Posted: Sun Jun 11, 2006 2:13 pm Newbie Joined: Sun Jun 11, 2006 10:24 am Posts: 9 Hi All, I have a big problem with optimistic lock. I have two threads that update at the same time the value of property 'pending' of class IcCredito. When one thread modify the ...

54. problem in optimistic lock implementation    forum.hibernate.org

Hi... There is a problem in optimistic lock implementation... I have this entry in my mapping file and the timestamp field is: The behavior observed in the application is that when we try to update the record using saveOrUpdate method it attempts to insert though the primary key value is provided... Please let ...

55. About other ways to implement optimistic locking    forum.hibernate.org

56. Locking problem    forum.hibernate.org

...

57. how to obtain a exclusive lock?    forum.hibernate.org

Environment: Hibernate3.0 SQLServer 2005, SQLJDBC 2005 Statement: Session sess=HiberanteUtil.getSession(); Transaction tx=sess.beginTransaction(); int id=1; User user=sess.get(User.class,id,LockMode.UPGRADE); user.set... //5th line ... when I debugged the program,I found two running threads reach the 5th line same time,which means they both obtained the exclusive locks of the same record.Didn't the get() method obtain the exclusive lock? furthermore,how to lock the hole db table. any answer ...

58. Problem with Lock    forum.hibernate.org

59. Hibernate Optimistic Locking Problem    forum.hibernate.org

Hi, I am trying to use hibernate optimistic locking on one of my entities. I have a field with JPA annotations as such: @Version @Column (name = "version_number") private Integer version; I have wiped the database to start afresh but something odd happens. I have created 3 new entities. When I modify the first hibernate runs update statements against the first ...

60. Disable optimistic locking    forum.hibernate.org

Why do you want to do that? Whatever the reason is: search for another sollution! I don't think that that what you want to do is possible. In the book "Java persistence with hibernate" the author describes how hibernate handles version's. Hibernate fires an update statement like this. Code: update MyTableName set version = .... where id = ...

61. optimistic locking application workaround    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.1.3 I am using optimistic locking with a Version column (Integer) in my hibernate-enabled application. I am trying to apply some logic for the case the user changed a list of objects (in a GUI table, for example), and tries to save them all. In case one of the ...

62. locking issues for large volume web application    forum.hibernate.org

First of all, this isn't a Hibernate issue. It's prolly a user issue and that's me :) I have a large volume web application with about 80k concurrent users during our 5 hour window of operation. I see a lot of errors in the logs regarding HibernateOptimisticLockingFailureException (StaleStateException, StaleObjectStateException). I'm curious if there is anything I can do to reduce the ...

63. Optimistic locking    forum.hibernate.org

64. locking and transactions    forum.hibernate.org

Hi, I've got a fairly basic question about locking and transactions but I can't find the answer anywhere. We're using JBoss EJB3s to handle all our DB work alongside Hibernate. Hibernate is hooked into the JBoss transaction manager and everything works fine. We're also using JBoss Cache as the 2nd level cache and again everything works fine. However, we're having a ...

65. Can I lock the reocrd on first request?    forum.hibernate.org

Hi, I am new in using hibernate and found an article related to "Open Session in View" pattern and have somes questions. http://www.hibernate.org/43.html 1. Can I lock the records (by select for update) when the first request arrived on the server, and then display the data on the page, after user updated the data and click submit, I update the records ...

66. How to bypass Optimistic Locking?    forum.hibernate.org

Hi, i'm using Hibernate Annotations with optimistic locking (@version) which works very well. The StaleObjectStateException will be thrown while trying to save an expired object graph. Now in some circumstances I want to bypass optimistic locking. I want to save objects with expired versions so that no StaleObjectStateException will be thrown. Is there any automatism for this usecase? Updating the versions ...

67. Optimistic Locking    forum.hibernate.org

TABLE ----------------------------------------------------------------------------- | COLUMNA | COLUMNB | COLUMNC | TIMESTAMP | |--------------------------------------------------------------------------- | A1 | B1 | C1 | T1 | |---------------------------------------------------------------------------- | A2 | B2 | C2 | T2 | ----------------------------------------------------------------------------- I am using Optimistic Locking Timestamp,All Strategy.In the above table 1.User 1 fetch the record based on where condition 'B1' 2.User 2 fetch the record based on where condition ...

69. Trying to understand locking (using JPA)    forum.hibernate.org

Sorry if this is a dumb question - I've got an object "Subscription" which I want to edit concurrently. Because when editing subscriptions I also send emails, charge credit cards, etc.. I can't rely on the "OptimisticLockException" that hibernate will throw if the version number is off. Originally, I just used code like: Code: Subscription s = em.get(subId); em.lock(s, LockModeType.READ); From ...

70. Dead Lock    forum.hibernate.org

Hi all, We are using Sturts,Ejb and Hibernate with Oracle 10g database with clustered environment for our application.When we do more number of transaction in a particular day, then always only one table is geeting locked and we are getting the following exception.At this time we are executing normal delete query. [3/24/09 10:23:07:084 GST] 00000080 SystemErr R org.hibernate.exception.LockAcquisitionException: could not execute ...

71. hibernate SQLQuery locked    forum.hibernate.org

72. Locking in hibernate    forum.hibernate.org

73. Optimistic Locking Issue    forum.hibernate.org

We have a web app using Hibernate 3.2.6 that uses automatic versioning for all objects using a timestamp as the version attribute. We have two cases where we consistently get StaleObjectStateExceptions when we know we are the only user accessing a particular piece of data. The exceptions are thrown when Hibernate tries to flush an object that has been modified in ...