Am new to hibernate. Am trying to update a table and ended up getting 
java.sql.SQLIntegrityConstraintViolationException: Duplicate entry for key 'PRIMARY' exception
Am using entityManager.merge() method to update the table.
Below are the table relationships
TableA( 
@ID 
int col A , 
String colB....)
TableB( 
@ID 
int col X , 
@ManyToOne 
@Id 
@JoinColumn(name = "colA",referencedColumnName = "colA") 
TableA tableA ....)
I have used Entitymanager.persist() to insert data in both the tables. Now i want to update the data in TableB. Below is my method for the same
public void update(List<TableBObj> TableBObjList){
    for(TableBObj tableBObj: TableBObjList){
            em.merge(tableBObj);
        }
    }
}
Currently getting "Duplicate entry for key". Seeing the logs merge method isn't running update query but its running insert query instead. Any help appreciated?
