1 30 package com.genimen.djeneric.repository; 31 32 import com.genimen.djeneric.repository.exceptions.DjenericException; 33 34 40 public abstract class DjIdProvider 41 { 42 50 public abstract long getNextId(DjSession forSession) throws DjenericException; 51 52 54 int _cacheSize = 5; 55 String _sequenceName; 56 57 60 public DjIdProvider() 61 62 { 63 } 64 65 70 public DjIdProvider(int cacheSize) 71 { 72 _cacheSize = cacheSize; 73 } 74 75 80 public int getCacheSize() 81 { 82 return _cacheSize; 83 } 84 85 90 public void setSequenceName(String sequenceName) 91 { 92 _sequenceName = sequenceName; 93 } 94 95 100 public String getSequenceName() 101 { 102 return _sequenceName; 103 } 104 105 112 public long getNextId(DjPersistenceManager mgr) throws DjenericException 113 { 114 DjSession session = mgr.createSession(); 115 try 116 { 117 long id = getNextId(session); 118 if (mgr.shouldTrace(DjPersistenceManager.TRACE_INTERNAL)) mgr.trace("Allocated new object id: " + id); 119 return id; 120 } 121 finally 122 { 123 session.close(); 124 } 125 } 126 127 } | Popular Tags |