public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) throws SQLException { // typically if one version column is in the result, they all are, so // optimize by checking for the first one before doing any real work Column[] cols = vers.getColumns(); if (!res.contains(cols[0], joins)) { return null; } Object version = populateFromResult(res, joins); // OPENJPA-662 Allow a null StateManager because this method may just be // invoked to get the result of projection query if (sm != null) { sm.setVersion(version); } return version; }
public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) throws SQLException { // typically if one version column is in the result, they all are, so // optimize by checking for the first one before doing any real work Column[] cols = vers.getColumns(); if (!res.contains(cols[0], joins)) { return null; } Object version = populateFromResult(res, joins); // OPENJPA-662 Allow a null StateManager because this method may just be // invoked to get the result of projection query if (sm != null) { sm.setVersion(version); } return version; }
public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) throws SQLException { // typically if one version column is in the result, they all are, so // optimize by checking for the first one before doing any real work Column[] cols = vers.getColumns(); if (!res.contains(cols[0], joins)) { return null; } Object version = populateFromResult(res, joins); // OPENJPA-662 Allow a null StateManager because this method may just be // invoked to get the result of projection query if (sm != null) { sm.setVersion(version); } return version; }
public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) throws SQLException { // typically if one version column is in the result, they all are, so // optimize by checking for the first one before doing any real work Column[] cols = vers.getColumns(); if (!res.contains(cols[0], joins)) { return null; } Object version = populateFromResult(res, joins); // OPENJPA-662 Allow a null StateManager because this method may just be // invoked to get the result of projection query if (sm != null) { sm.setVersion(version); } return version; }
public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) throws SQLException { Column[] cols = vers.getColumns(); Select sel = store.getSQLFactory().newSelect(); sel.select(cols); sel.wherePrimaryKey(sm.getObjectId(), vers.getClassMapping(), store); // No need to lock version field (i.e. optimistic), except when version update is required (e.g. refresh) JDBCFetchConfiguration fetch = store.getFetchConfiguration(); if (!updateVersion && fetch.getReadLockLevel() >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { fetch = (JDBCFetchConfiguration) fetch.clone(); fetch.setReadLockLevel(MixedLockLevels.LOCK_NONE); } Result res = sel.execute(store, fetch); try { if (!res.next()) return false; Object memVersion = sm.getVersion(); Object dbVersion = populateFromResult(res, null); boolean refresh = compare(memVersion, dbVersion) < 0; if (updateVersion) sm.setVersion(dbVersion); return !refresh; } finally { res.close(); } }
public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) throws SQLException { Column[] cols = vers.getColumns(); Select sel = store.getSQLFactory().newSelect(); sel.select(cols); sel.wherePrimaryKey(sm.getObjectId(), vers.getClassMapping(), store); // No need to lock version field (i.e. optimistic), except when version update is required (e.g. refresh) JDBCFetchConfiguration fetch = store.getFetchConfiguration(); if (!updateVersion && fetch.getReadLockLevel() >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { fetch = (JDBCFetchConfiguration) fetch.clone(); fetch.setReadLockLevel(MixedLockLevels.LOCK_NONE); } Result res = sel.execute(store, fetch); try { if (!res.next()) return false; Object memVersion = sm.getVersion(); Object dbVersion = populateFromResult(res, null); boolean refresh = compare(memVersion, dbVersion) < 0; if (updateVersion) sm.setVersion(dbVersion); return !refresh; } finally { res.close(); } }
public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) throws SQLException { Column[] cols = vers.getColumns(); Select sel = store.getSQLFactory().newSelect(); sel.select(cols); sel.wherePrimaryKey(sm.getObjectId(), vers.getClassMapping(), store); // No need to lock version field (i.e. optimistic), except when version update is required (e.g. refresh) JDBCFetchConfiguration fetch = store.getFetchConfiguration(); if (!updateVersion && fetch.getReadLockLevel() >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { fetch = (JDBCFetchConfiguration) fetch.clone(); fetch.setReadLockLevel(MixedLockLevels.LOCK_NONE); } Result res = sel.execute(store, fetch); try { if (!res.next()) return false; Object memVersion = sm.getVersion(); Object dbVersion = populateFromResult(res, null); boolean refresh = compare(memVersion, dbVersion) < 0; if (updateVersion) sm.setVersion(dbVersion); return !refresh; } finally { res.close(); } }
public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) throws SQLException { Column[] cols = vers.getColumns(); Select sel = store.getSQLFactory().newSelect(); sel.select(cols); sel.wherePrimaryKey(sm.getObjectId(), vers.getClassMapping(), store); // No need to lock version field (i.e. optimistic), except when version update is required (e.g. refresh) JDBCFetchConfiguration fetch = store.getFetchConfiguration(); if (!updateVersion && fetch.getReadLockLevel() >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { fetch = (JDBCFetchConfiguration) fetch.clone(); fetch.setReadLockLevel(MixedLockLevels.LOCK_NONE); } Result res = sel.execute(store, fetch); try { if (!res.next()) return false; Object memVersion = sm.getVersion(); Object dbVersion = populateFromResult(res, null); boolean refresh = compare(memVersion, dbVersion) < 0; if (updateVersion) sm.setVersion(dbVersion); return !refresh; } finally { res.close(); } }