protected long getUniqueLong ( FieldDescriptor field ) throws SequenceManagerException { long result ; // lookup sequence name String sequenceName = calculateSequenceName ( field ) ; try { result = buildNextSequence ( field . getClassDescriptor ( ) , sequenceName ) ; } catch ( Throwable e ) { // maybe the sequence was not created try { log . info ( "Create DB sequence key '" + sequenceName + "'" ) ; createSequence ( field . getClassDescriptor ( ) , sequenceName ) ; } catch ( Exception e1 ) { throw new SequenceManagerException ( SystemUtils . LINE_SEPARATOR + "Could not grab next id, failed with " + SystemUtils . LINE_SEPARATOR + e . getMessage ( ) + SystemUtils . LINE_SEPARATOR + "Creation of new sequence failed with " + SystemUtils . LINE_SEPARATOR + e1 . getMessage ( ) + SystemUtils . LINE_SEPARATOR , e1 ) ; } try { result = buildNextSequence ( field . getClassDescriptor ( ) , sequenceName ) ; } catch ( Throwable e1 ) { throw new SequenceManagerException ( "Could not grab next id, sequence seems to exist" , e ) ; } } return result ; }
returns a unique long value for class clazz and field fieldName . the returned number is unique accross all tables in the extent of clazz .