List of usage examples for org.apache.ibatis.session SqlSession commit
void commit();
From source file:net.landora.animeinfo.data.AnimeDBA.java
License:Open Source License
public static void saveListItem(AnimeListItem list) { SqlSession session = null; try {// w w w.ja v a 2 s.c o m session = AnimeDataManager.getInstance().openSession(); AnimeMapper mapper = session.getMapper(AnimeMapper.class); int rows = mapper.updateListItem(list); if (rows == 0) { mapper.insertListItem(list); } session.commit(); myListCache.put(list.getFile().getFileId(), list); } catch (Exception e) { session.rollback(); log.error("Error saving list item.", e); } finally { if (session != null) { session.close(); } } }
From source file:net.landora.animeinfo.data.AnimeDBA.java
License:Open Source License
public static void deleteListItem(AnimeListItem list) { SqlSession session = null; try {//from www . j a v a2 s . c om session = AnimeDataManager.getInstance().openSession(); AnimeMapper mapper = session.getMapper(AnimeMapper.class); mapper.deleteListItem(list); session.commit(); myListCache.put(list.getFile().getFileId(), null); } catch (Exception e) { session.rollback(); log.error("Error saving list item.", e); } finally { if (session != null) { session.close(); } } }
From source file:net.landora.animeinfo.data.AnimeDBA.java
License:Open Source License
public static boolean saveAnimeNotification(AnimeNotification notification) { SqlSession session = null; try {/*from w ww.j a v a 2 s . co m*/ session = AnimeDataManager.getInstance().openSession(); AnimeMapper mapper = session.getMapper(AnimeMapper.class); int rows = mapper.updateAnimeNotification(notification); if (rows == 0) { mapper.insertAnimeNotification(notification); } session.commit(); notificationCache.put(notification.getFile().getFileId(), notification); return true; } catch (Exception e) { log.error("Error saving list item.", e); if (session != null) { session.rollback(); } return false; } finally { if (session != null) { session.close(); } } }
From source file:net.landora.animeinfo.data.AnimeDBA.java
License:Open Source License
public static boolean markDownloadedEpisodesAsCompletedNotifications() { SqlSession session = null; try {//www . j a va 2 s .c om session = AnimeDataManager.getInstance().openSession(); AnimeMapper mapper = session.getMapper(AnimeMapper.class); mapper.markDownloadedEpisodesAsCompleted(); session.commit(); notificationCache.getCache().removeAll(); return true; } catch (Exception e) { log.error("Error saving list item.", e); if (session != null) { session.rollback(); } return false; } finally { if (session != null) { session.close(); } } }
From source file:net.landora.animeinfo.data.AnimeDBA.java
License:Open Source License
public static boolean saveAnimeMessage(AnimeMessage msg) { SqlSession session = null; try {// www. j a v a 2s .c om session = AnimeDataManager.getInstance().openSession(); AnimeMapper mapper = session.getMapper(AnimeMapper.class); int rows = mapper.updateAnimeMessage(msg); if (rows == 0) { mapper.insertAnimeMessage(msg); } session.commit(); return true; } catch (Exception e) { log.error("Error saving message.", e); if (session != null) { session.rollback(); } return false; } finally { if (session != null) { session.close(); } } }
From source file:net.landora.animeinfo.data.AnimeDBA.java
License:Open Source License
public static void saveAnimePicture(String filename, byte[] data) { SqlSession session = null; try {/*from w w w.j ava 2 s . co m*/ session = AnimeDataManager.getInstance().openSession(); AnimeMapper mapper = session.getMapper(AnimeMapper.class); mapper.insertAnimePicture(filename, data); session.commit(); } catch (Exception e) { session.rollback(); log.error("Error saving anime picture.", e); } finally { if (session != null) { session.close(); } } }
From source file:net.landora.video.filestate.data.SharedDirectoryDBA.java
License:Open Source License
public static void saveSharedDirectory(SharedDirectory dir) { SqlSession session = null; try {// ww w.j a va 2 s . c om session = FileStateDataManager.getInstance().openSession(); SharedDirectoryMapper mapper = session.getMapper(SharedDirectoryMapper.class); if (dir.getDirectoryId() < 1) { mapper.insertSharedDirectory(dir); } else { mapper.updateSharedDirectory(dir); } session.commit(); } catch (Exception e) { log.error("Error saving SharedDirectory.", e); if (session != null) { session.rollback(); } } finally { if (session != null) { session.close(); } } }
From source file:net.landora.video.filestate.data.SharedDirectoryDBA.java
License:Open Source License
public static void saveFileRecord(FileRecord file) { SqlSession session = null; try {/* www .j a v a2 s . c o m*/ session = FileStateDataManager.getInstance().openSession(); SharedDirectoryMapper mapper = session.getMapper(SharedDirectoryMapper.class); if (file.getFileId() < 1) { mapper.insertFileRecord(file); } else { mapper.updateFileRecord(file); } session.commit(); } catch (Exception e) { log.error("Error saving FileRecord.", e); if (session != null) { session.rollback(); } } finally { if (session != null) { session.close(); } } }
From source file:net.landora.video.filestate.data.SharedDirectoryDBA.java
License:Open Source License
public static void deleteFileRecord(FileRecord file) { SqlSession session = null; try {//from w w w . jav a 2 s . c o m session = FileStateDataManager.getInstance().openSession(); SharedDirectoryMapper mapper = session.getMapper(SharedDirectoryMapper.class); mapper.deleteFileRecord(file); session.commit(); } catch (Exception e) { log.error("Error deleting FileRecord.", e); if (session != null) { session.rollback(); } } finally { if (session != null) { session.close(); } } }
From source file:net.landora.video.preferences.PreferencesDBA.java
License:Open Source License
public static void setExtensions(Collection<String> extensions) { SqlSession session = null; try {/* w w w .ja va2s. c o m*/ session = PreferencesDataManager.getInstance().openSession(); PreferencesMapper mapper = session.getMapper(PreferencesMapper.class); mapper.deleteVideoExtensions(); for (String extension : extensions) { mapper.insertVideoExtension(extension); } session.commit(); } catch (Exception e) { log.error("Error saving extensions.", e); session.rollback(); } finally { if (session != null) { session.close(); } } }