@ExceptionHandler(Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void saveImage(Hotel hotel, String fileName, InputStream inputStream) throws Exception { String dirPath = Config.HOTELS_FILES_DIR + hotel.getId(); String filepath = FileDataStore.saveFile(dirPath, fileName, inputStream); hotel.getImages().add(new Image(filepath)); hotelDAO.merge(hotel); // Обновитть теперь // System.out.println(">>>>@@@@"); // throw new Exception("!!!!!"); }
@Transactional(propagation = Propagation.REQUIRED, readOnly = true) public Hotel lazyLoad(Long id) throws Exception { Hotel hotel = hotelDAO.find(id); if (hotel != null) { if (hotel.getImages() != null) { hotel.getImages().size(); } if (hotel.getResortTypes() != null) { hotel.getResortTypes().size(); } } return hotel; }
@Transactional(propagation = Propagation.REQUIRED, readOnly = true) public List<Hotel> findByLocations(List<Location> llist) throws Exception { return hotelDAO.executeQueryByName("Hotel.findBylocation", new Object[] {llist}); }