Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPA Lock Table

 
Sergey Yegres
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to lock table. If I am correct JPA suppose to have a lock only for a single record. So the only approach I have to create another table with the record indicating the table is locked. Is it right?

Table A { } // this entire table I need to lock

Table B { table_A_locked INT } // get a lock on this record to lock table A

Is it the only solution for locking "Table A"?

I don't know if it's safe to call native SQL to lock table. Any help will be great.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really need to lock a table, then just execute the SQL as a native SQL query (provided your database supports this syntax).

Otherwise, why are you trying to lock the entire table?
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!