Skip to content

Commit

Permalink
fix for a possible table lock issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Apr 19, 2013
1 parent f07c603 commit b0779e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -14,8 +14,6 @@ public interface ISequenceService {
public long currVal(ISqlTransaction transaction, String name);

public void create(Sequence sequence);

public Sequence get(String name);

public void init();

Expand Down
@@ -1,6 +1,8 @@
package org.jumpmind.symmetric.service.impl;

import java.sql.Types;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jumpmind.db.sql.ISqlRowMapper;
Expand Down Expand Up @@ -82,7 +84,7 @@ protected long tryToGetNextVal(ISqlTransaction transaction, String name) {
long currVal = currVal(transaction, name);
Sequence sequence = sequenceDefinitionCache.get(name);
if (sequence == null) {
sequence = get(name);
sequence = get(transaction, name);
if (sequence != null) {
sequenceDefinitionCache.put(name, sequence);
} else {
Expand Down Expand Up @@ -140,8 +142,13 @@ public void create(Sequence sequence) {
sequence.getMaxValue(), sequence.isCycle() ? 1 : 0, sequence.getLastUpdateBy());
}

public Sequence get(String name) {
return sqlTemplate.queryForObject(getSql("getSequenceSql"), new SequenceRowMapper(), name);
protected Sequence get(ISqlTransaction transaction, String name) {
List<Sequence> values = transaction.query(getSql("getSequenceSql"), new SequenceRowMapper(), new Object[] {name}, new int [] {Types.VARCHAR});
if (values.size() > 0) {
return values.get(0);
} else {
return null;
}
}

class SequenceRowMapper implements ISqlRowMapper<Sequence> {
Expand Down

0 comments on commit b0779e5

Please sign in to comment.