1 18 package org.objectweb.jorm.facility.naming.rdbsequence; 19 20 import org.objectweb.jorm.facility.naming.generator.LongGen; 21 import org.objectweb.jorm.api.PException; 22 import org.objectweb.jorm.api.PMapper; 23 import org.objectweb.jorm.mapper.rdb.lib.RdbConnectionWrapper; 24 import org.objectweb.jorm.mapper.rdb.lib.PMapperRdb; 25 26 import java.sql.Connection ; 27 28 32 public class RdbSequenceLongGen 33 extends RdbSequenceHelper 34 implements LongGen { 35 36 private PMapper mapper; 37 38 public RdbSequenceLongGen(PMapperRdb mapper, String seqName, boolean sequenceCreated) { 39 super(mapper.getRdbAdapter(), seqName, sequenceCreated); 40 this.mapper = mapper; 41 } 42 43 public long genId() throws PException { 44 Object conn = mapper.getConnection(); 45 try { 46 return genId(conn); 47 } finally { 48 mapper.closeConnection(conn); 49 } 50 } 51 52 public long genId(Object _conn) throws PException { 53 Connection conn = RdbConnectionWrapper.narrow2SQL(_conn); 54 return allocateId(conn); 55 } 56 } 57 | Popular Tags |