下面是我的DAO Impl方法,该方法调用数据库,在单线程中工作正常,但是当我在多节点环境中部署时获取错误并锁定不被释放
@Transactional
public long getSequenceUniqueId()throws Exception {
Session session = sessionFactory.getCurrentSession();
long minVal = 0L;
long maxVal = 0L;
long existingId=0L;
try
{
MySequence myEntityObj = (MySequence) session.load(MySequence.class, ID, LockMode.UPGRADE);
existingId=myEntityObj.getSequence();
maxVal=myEntityObj.getMaxVal();
minVal=myEntityObj.getMinVal();
existingId = existingId+1;
myEntityObj.setSequence(existingId);
session.update(myEntityObj);
session.flush();
}catch(Exception lAE)
{
lAE.printStackTrace();
}
return existingId;
}
答案 0 :(得分:0)
尝试在finally子句中刷新和关闭:
<Rs rsId="98324" snpClass="snp" snpType="notwithdrawn"
molType="genomic" genotype="true"bitField="050028000005130500030100"
taxId="9606">
<Het type="est" value="0.05" stdError="0.1547"/>
<Validation byCluster="true" byOtherPop="true" byHapMap="true"
by1000G="true">
<otherPopBatchId>7179</otherPopBatchId>
</Validation>
<Create build="36" date="2000-09-19 17:02"/>
<Update build="144" date="2015-05-07 10:52"/>
<Sequence exemplarSs="491581208" ancestralAllele="C,C">
<Seq5>
ATAAGCAAATAACTGAAGTTTAATCAGTCTCCTCCCAGCAAGTGATATGCAACTGAGATTCC
TTATGACACATCTGAACACTAGTGGATTTGCTTTGTAGTAGGAACAA
GGTACATTCGCGGGATAAATGTGGCCAAGTTTTATCTGCTGCCAGGGCTTTCAAAT
AGGTTGACCTGACAATGGGTCACCTCTGGGACTGA</Seq5>
<Observed>C/T</Observed>
<Seq3>AATTAGGAAGAGCTGGTACCTAAAATGAAAGATGCCCTTAAATTTCAGATTCACAATTTTTT
TTTCTTAGTATAAGCATGTCCCATGTAATATCTGGGATATACTCATACCTT
TAAAAATGTGCTCATTGTTTATCTGAAATTCACATTTTAACAGGGAACCATTGT
TTTGTTATTGTTTATTGTTTTGTTTCTAAATAA</Seq3>
</Sequence>
<Ss ssId="1556770886" handle="1000GENOMES" batchId="1061891"
locSnpId="PHASE3_chrY_229259" subSnpClass="snp" orient="reverse"
strand="top" molType="genomic" buildId="144"
methodClass="sequence" validated="by-submitter">
<Sequence>
<Seq5>TTTTAGGTACCAGCTCTTCCTAATT</Seq5>
<Observed>A/G</Observed>
<Seq3>TCAGTCCCAGAGGTGACCCATTGTC</Seq3>
</Sequence>
</Ss>
<Assembly dbSnpBuild="144" genomeBuild="38.2"
groupLabel="GRCh38.p2" current="true" reference="true">
<Component componentType="contig" accession="NT_011875.13"
chromosome="Y" start="11642902" end="21789280"
orientation="fwd" gi="568801947" groupTerm="NC_000024.10"
contigLabel="GCF_000001405.28">
<MapLoc asnFrom="5341580" asnTo="5341580" locType="exact"
alnQuality="1" orient="reverse" physMapInt="16984482"
leftContigNeighborPos="5341579"rightContigNeighborPos="5341581"
refAllele="G"/>
</Component>
<SnpStat mapWeight="unique-in-contig" chromCount="1"
placedContigCount="1" unplacedContigCount="0" seqlocCount="1"
hapCount="0"/>
</Assembly>
<RsLinkout resourceId="1" linkValue="3894"/>
<RsLinkout resourceId="4" linkValue="60936"/>
<RsLinkout resourceId="5" linkValue="23388839"/>
<MergeHistory rsId="56546490" buildId="130"/>
<MergeHistory rsId="386588736" buildId="142"/>
<hgvs>NC_000024.9:g.19096363G>A</hgvs>
<hgvs>NC_000024.10:g.16984483G>A</hgvs>
<Frequency freq="0.0276" allele="A" sampleSize="1233"/>
</Rs>