added a new method to getting next id from sequence and bugfix for inserting the record with assigned id