List of usage examples for org.hibernate Session refresh
void refresh(Object object);
From source file:storybook.ui.table.renderer.LocationsTableCellRenderer.java
License:Open Source License
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);/* ww w . j av a2 s. c o m*/ if (value instanceof String) { return lbText; } else { @SuppressWarnings("unchecked") List<Location> list = (List<Location>) value; try { lbText.setText(StringUtils.join(list, ", ")); } catch (LazyInitializationException lie) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); for (Location location : list) { session.refresh(location); } lbText.setText(StringUtils.join(list, ", ")); model.commit(); } catch (Exception e) { e.printStackTrace(); } } return lbText; }
From source file:storybook.ui.table.renderer.PersonsTableCellRenderer.java
License:Open Source License
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);//from w w w . j av a2 s .c om if (value instanceof String) { return lbText; } @SuppressWarnings("unchecked") List<Person> list = (List<Person>) value; List<String> abbrList = new ArrayList<String>(); try { for (Person person : list) { abbrList.add(person.getAbbr()); // CleverLabel lb = new CleverLabel(person.getAbbr()); // lb.setBackground(person.getJColor()); // panel.add(lb); } } catch (LazyInitializationException lie) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); for (Person person : list) { session.refresh(person); abbrList.add(person.getAbbr()); } model.commit(); } catch (Exception e) { e.printStackTrace(); return lbText; } lbText.setText(" " + StringUtils.join(abbrList, ", ")); return lbText; }
From source file:storybook.ui.table.renderer.StrandsTableCellRenderer.java
License:Open Source License
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);// w w w.j a v a 2 s . c om if (value instanceof String) { return lbText; } List<String> abbrList = new ArrayList<String>(); try { @SuppressWarnings("unchecked") List<Strand> list = (List<Strand>) value; for (Strand strand : list) { abbrList.add(strand.getAbbr()); } } catch (LazyInitializationException lie) { BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); @SuppressWarnings("unchecked") List<Strand> list = (List<Strand>) value; for (Strand strand : list) { session.refresh(strand); abbrList.add(strand.getAbbr()); } model.commit(); } catch (Exception e) { e.printStackTrace(); return lbText; } lbText.setText(" " + StringUtils.join(abbrList, ", ")); return lbText; }
From source file:storybook.ui.table.renderer.StrandTableCellRenderer.java
License:Open Source License
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);//ww w.j a va 2 s. c om lbText.setBorder(SwingUtil.getBorder(Color.white, 2)); StrandLabel lbStrand = null; if (value == null || value instanceof String) { return lbText; } try { lbStrand = new StrandLabel((Strand) value); } catch (LazyInitializationException lie) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); session.refresh((Strand) value); lbStrand = new StrandLabel((Strand) value); model.commit(); } catch (Exception e) { e.printStackTrace(); } if (lbStrand != null) { lbStrand.setBackground(lbText.getBackground()); lbStrand.setOpaque(true); return lbStrand; } return lbText; }
From source file:uk.ac.ox.oucs.vle.CourseDAOImpl.java
License:Educational Community License
public void save(final CourseComponentDAO componentDao) { getHibernateTemplate().execute(new HibernateCallback<Object>() { @Override/*w w w .j a va 2 s.c o m*/ public Object doInHibernate(Session session) throws HibernateException, SQLException { session.saveOrUpdate(componentDao); for (CourseGroupDAO group : componentDao.getGroups()) { session.refresh(group); } return null; } }); getHibernateTemplate().saveOrUpdate(componentDao); }