List of usage examples for org.hibernate LockOptions NONE
LockOptions NONE
To view the source code for org.hibernate LockOptions NONE.
Click Source Link
From source file:ca.mcgill.cs.swevo.qualyzer.model.PersistenceManager.java
License:Open Source License
/** * /* w w w . ja v a 2 s .c om*/ * Does something. * * @param project * @return */ public void initializeDocument(IAnnotatedDocument document) { HibernateDBManager dbManager = fActivator.getHibernateDBManagers() .get(document.getProject().getFolderName()); Session session = dbManager.openSession(); try { // Reattach session.buildLockRequest(LockOptions.NONE).lock(document); Hibernate.initialize(document.getParticipants()); Hibernate.initialize(document.getFragments()); } finally { HibernateUtil.quietClose(session); } }
From source file:com.algoTrader.service.TransactionServiceImpl.java
License:Open Source License
protected void handleCreateTransaction(Fill fill) throws Exception { Strategy strategy = fill.getParentOrder().getStrategy(); Security security = fill.getParentOrder().getSecurity(); // lock and initialize the security & strategy Session session = this.getSessionFactory().getCurrentSession(); session.buildLockRequest(LockOptions.NONE).lock(security); session.buildLockRequest(LockOptions.NONE).lock(strategy); Hibernate.initialize(security);/*w w w .ja va 2 s . c o m*/ Hibernate.initialize(strategy); TransactionType transactionType = Side.BUY.equals(fill.getSide()) ? TransactionType.BUY : TransactionType.SELL; long quantity = Side.BUY.equals(fill.getSide()) ? fill.getQuantity() : -fill.getQuantity(); Transaction transaction = new TransactionImpl(); transaction.setDateTime(fill.getDateTime()); transaction.setQuantity(quantity); transaction.setPrice(fill.getPrice()); transaction.setType(transactionType); transaction.setSecurity(security); transaction.setStrategy(strategy); transaction.setCurrency(security.getSecurityFamily().getCurrency()); transaction.setCommission(fill.getCommission()); // Strategy strategy.getTransactions().add(transaction); // Position Position position = getPositionDao().findBySecurityAndStrategy(security.getId(), strategy.getName()); if (position == null) { position = new PositionImpl(); position.setQuantity(transaction.getQuantity()); position.setExitValue(null); position.setMaintenanceMargin(null); position.setSecurity(security); security.getPositions().add(position); position.getTransactions().add(transaction); transaction.setPosition(position); position.setStrategy(strategy); strategy.getPositions().add(position); getPositionDao().create(position); } else { position.setQuantity(position.getQuantity() + transaction.getQuantity()); if (!position.isOpen()) { position.setExitValue(null); position.setMaintenanceMargin(null); } position.getTransactions().add(transaction); transaction.setPosition(position); getPositionDao().update(position); } getTransactionDao().create(transaction); getStrategyDao().update(strategy); getSecurityDao().update(security); // progapate the order to all corresponding esper engines propagateTransaction(transaction); String logMessage = "executed transaction type: " + transactionType + " quantity: " + transaction.getQuantity() + " of " + security.getSymbol() + " price: " + transaction.getPrice() + " commission: " + transaction.getCommission(); logger.info(logMessage); }
From source file:com.algoTrader.util.HibernateUtil.java
License:Open Source License
public static boolean lock(SessionFactory sessionFactory, Object target) { Session session = sessionFactory.getCurrentSession(); try {/*from w w w.j av a 2 s . c o m*/ session.buildLockRequest(LockOptions.NONE).lock(target); return true; } catch (NonUniqueObjectException e) { // different object with the same identifier value was already associated with the session return false; } }
From source file:com.lewischooman.dao.MovieShowDAO.java
License:Open Source License
@Override public MovieShowDB getMovieShowById(Integer movieShowId) { return this.getMovieShowById(movieShowId, LockOptions.NONE); }
From source file:Dao.CompanyinfoDAO.java
public void attachClean(Companyinfo instance) { log.debug("attaching clean Companyinfo instance"); try {//from w w w. j av a2 s. c o m getCurrentSession().buildLockRequest(LockOptions.NONE).lock(instance); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } }
From source file:de.tudarmstadt.ukp.wikipedia.api.hibernate.CategoryDAO.java
License:Apache License
public void attachClean(Category instance) { logger.debug("attaching clean Category instance"); try {/*from w w w. ja v a2s .c om*/ // sessionFactory.getCurrentSession().lock(instance, LockMode.NONE); sessionFactory.getCurrentSession().buildLockRequest(LockOptions.NONE).lock(instance); logger.debug("attach successful"); } catch (RuntimeException re) { logger.error("attach failed", re); throw re; } }
From source file:de.tudarmstadt.ukp.wikipedia.api.hibernate.MetaDataDAO.java
License:Apache License
public void attachClean(MetaData instance) { logger.debug("attaching clean MetaData instance"); try {// ww w .j a v a2 s . c o m // sessionFactory.getCurrentSession().lock(instance, LockMode.NONE); sessionFactory.getCurrentSession().buildLockRequest(LockOptions.NONE).lock(instance); logger.debug("attach successful"); } catch (RuntimeException re) { logger.error("attach failed", re); throw re; } }
From source file:de.tudarmstadt.ukp.wikipedia.api.hibernate.PageDAO.java
License:Apache License
public void attachClean(Page instance) { logger.debug("attaching clean Page instance"); try {//from w w w . ja v a2s.c om // sessionFactory.getCurrentSession().lock(instance, LockMode.NONE); sessionFactory.getCurrentSession().buildLockRequest(LockOptions.NONE).lock(instance); logger.debug("attach successful"); } catch (RuntimeException re) { logger.error("attach failed", re); throw re; } }
From source file:de.tudarmstadt.ukp.wikipedia.api.Page.java
License:Apache License
/** * Returns a set of categories that this page belongs to. * * @return The a set of categories that this page belongs to. *//*from ww w . jav a 2 s.c o m*/ public Set<Category> getCategories() { Session session = this.wiki.__getHibernateSession(); session.beginTransaction(); session.buildLockRequest(LockOptions.NONE).lock(hibernatePage); Set<Integer> tmp = new UnmodifiableArraySet<Integer>(hibernatePage.getCategories()); session.getTransaction().commit(); Set<Category> categories = new HashSet<Category>(); for (int pageID : tmp) { categories.add(wiki.getCategory(pageID)); } return categories; }
From source file:de.tudarmstadt.ukp.wikipedia.api.Page.java
License:Apache License
/** * Returns the set of pages that have a link pointing to this page. <b>Warning:</b> Do not use * this for getting the number of inlinks with getInlinks().size(). This is too slow. Use * getNumberOfInlinks() instead./* ww w . ja v a2 s . co m*/ * * @return The set of pages that have a link pointing to this page. */ public Set<Page> getInlinks() { Session session = wiki.__getHibernateSession(); session.beginTransaction(); session.buildLockRequest(LockOptions.NONE).lock(hibernatePage); // Have to copy links here since getPage later will close the session. Set<Integer> pageIDs = new UnmodifiableArraySet<Integer>(hibernatePage.getInLinks()); session.getTransaction().commit(); Set<Page> pages = new HashSet<Page>(); for (int pageID : pageIDs) { try { pages.add(wiki.getPage(pageID)); } catch (WikiApiException e) { // Silently ignore if a page could not be found // There may be inlinks that do not come from an existing page. continue; } } return pages; }