add save method to save entities to database.