Lock only Single Record Using JPA/Hibernate

Hi,
I need to lock only single record from a table.
I am trying with following code.

Map<String, Object> properties = new HashMap<>();
properties.put(“javax.persistence.lock.timeout”, 0L);
entityManager.find(MyEntity.class, myParam, LockModeType.PESSIMISTIC_READ, myProperties);

But it is locking entire Table not just the record.
Any Suggestions

It is Acquiring Lock now for a single record with the below changed .

Map<String, Object> properties = new HashMap<>();
properties.put(“javax.persistence.lock.timeout”, 0L);
myEntity = entityManager.find(MyEntity.class, myParam);
entityManager.lock(myEntity,LockModeType.PESSIMISTIC_WRITE,properties);

But the question is, it is not Timing Out even though i have mentioned it as 0L. It is taking some time to throw LockTimeoutException Or OptimisticLockException