Concurrent updates to oracle table in Java
===

<br />
I'm developing an application with some kind of 'facebook like' feature. Every time that a content published by a user is 'liked' he will have his punctuation increased. This app will be used by a large number of users around the company, so We are expecting a lot of concurrent updates to the same row.

*simplified code*

User punctuation table
-----
<!-- language: sql -->

    Punctuation(
        userId NVARCHAR2(32),
        value NUMBER(10,0)
    )/

<br />
Java code
---

<!-- language: java -->

    public class Punctuation(){
        private String userId;
        private int value;

        public Punctuation(final String userId, final int value){
                this.userId = userId;
                this.value = value;
        }

        public String getUserId();
        public int getValue();

    }

    //simplified code
    public final class PunctuationController{
    
        private PunctuationController(){}
    
        public static void addPunctuation(final Punctuation punctuation){
    
            final Transaction transaction = TransactionFactory.createTransaction();
            Connection conn = null;
            PreparedStatment statment = null;
            try{
                    synchronized(punctuation){
                        transaction.begin();
                        conn = transaction.getConnection();
                        statment = conn.preparedStatment("UPDATE Punctuation SET value = value + ? where userId = ?");
                        statment.setString('1', punctuation.getUserId());
                        statment.setInt('2', punctuation.getValue());
                        transaction.commit();
                    }
            }catch (Exception e){
                    transaction.rollback();
            }finally{
                    transaction.dispose();
                    if(statment !=null){
                            statment.close();
                    }
            }
    }


<br /><br />
We are afraid of deadlocks during updates. Oracle allows to make the sum on a single query, I don't have to retrieve the value and make a second query to update with a new value, that's good. Also reading some other posts here, They said to create a synchronized block to lock an object, and let Java handle the synchronization between different threads. I choose the punctuation instance the method receives, this way I imagine that different combinations of user and value will allow concurrent acess to this methods, but will block an instance with same values (Do I have to implement equals() on Punctuation?)
<br/><br/>
Our database is Oracle 10g, Server Weblogic 11g, Java 6 and Linux (I dont know which flavor).
<br /><br />
Thank you in advance!