Your understanding is only partially correct.
In your example with InventSum, you forgot to take OccEnabled property into account. It's No in this case, therefore queries to InventSum are pessimistically-locked by default and using pessimisticLock in a query has no effect. It would make sense for a table with OccEnabled=Yes.
You're also wrong about concurrencyModel() method. If you look at the method signature or its documentation, you'll find that it accepts a parameter, therefore you can use it to change the concurrency model at runtime. You can use Find references on ConcurrencyModel EDT to find examples in the application. One of them is in AccountingDistribution::find():
public static AccountingDistribution find(
AccountingDistributionRecId _recId,
boolean _forupdate = false,
ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
AccountingDistribution accountingDistribution;
;
accountingDistribution.selectForUpdate(_forupdate);
if (_forupdate && _concurrencyModel != ConcurrencyModel::Auto)
{
accountingDistribution.concurrencyModel(_concurrencyModel);
}
...