public void Update(PlaylistItem playlistItem) { try { NHibernateSessionManager.Instance.BeginTransaction(); playlistItem.ValidateAndThrow(); playlistItem.Video.ValidateAndThrow(); PlaylistItem knownPlaylistItem = PlaylistItemDao.Get(playlistItem.Id); if (knownPlaylistItem == null) { PlaylistItemDao.Update(playlistItem); } else { PlaylistItemDao.Merge(playlistItem); } NHibernateSessionManager.Instance.CommitTransaction(); } catch (Exception exception) { Logger.Error(exception); NHibernateSessionManager.Instance.RollbackTransaction(); throw; } }
/// <summary> /// This is the work for saving a PlaylistItem without the Transaction wrapper. /// </summary> private void DoSave(PlaylistItem playlistItem) { // This is a bit of a hack, but NHibernate pays attention to the "dirtyness" of immutable entities. // As such, if two PlaylistItems reference the same Video object -- NonUniqueObjectException is thrown even though no changes // can be persisted to the database. playlistItem.Video = VideoDao.Merge(playlistItem.Video); playlistItem.ValidateAndThrow(); playlistItem.Video.ValidateAndThrow(); PlaylistItemDao.Save(playlistItem); }
private void DoUpdate(PlaylistItem playlistItem) { playlistItem.ValidateAndThrow(); playlistItem.Video.ValidateAndThrow(); PlaylistItem knownPlaylistItem = PlaylistItemDao.Get(playlistItem.Id); if (knownPlaylistItem == null) { PlaylistItemDao.Update(playlistItem); } else { PlaylistItemDao.Merge(playlistItem); } }
/// <summary> /// This is the work for saving a PlaylistItem without the Transaction wrapper. /// </summary> private void DoSave(PlaylistItem playlistItem) { playlistItem.ValidateAndThrow(); PlaylistItemDao.Save(playlistItem); }
private void DoUpdate(PlaylistItem playlistItem) { playlistItem.ValidateAndThrow(); PlaylistItemDao.Update(playlistItem); }