com.gs.fw.common.mithra.MithraTransaction Java Examples
The following examples show how to use
com.gs.fw.common.mithra.MithraTransaction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestDirectRefRelationships.java From reladomo with Apache License 2.0 | 6 votes |
private void copyOrder(final DirectRefOrder order) { final int[] count = new int[1]; MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { order.copyDetachedValuesToOriginalOrInsertIfNew(); if (count[0] == 0) { count[0] = 1; MithraBusinessException excp = new MithraBusinessException("for testing retry"); excp.setRetriable(true); throw excp; } return null; } }); }
Example #2
Source File: TestTransactionalObject.java From reladomo with Apache License 2.0 | 6 votes |
public void testSetPrimitiveAttributeToNullToDatedObject() { final Timestamp businessDate = new Timestamp(System.currentTimeMillis()); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { TestAgeBalanceSheetRunRate rate = new TestAgeBalanceSheetRunRate(businessDate); rate.setTradingdeskLevelTypeId(11); rate.setTradingDeskorDeskHeadId(1001); rate.setNullablePrimitiveAttributesToNull(); rate.insert(); return null; } }); TestAgeBalanceSheetRunRateFinder.clearQueryCache(); Operation op = TestAgeBalanceSheetRunRateFinder.businessDate().eq(businessDate); op = op.and(TestAgeBalanceSheetRunRateFinder.tradingdeskLevelTypeId().eq(11)); op = op.and(TestAgeBalanceSheetRunRateFinder.tradingDeskorDeskHeadId().eq(1001)); TestAgeBalanceSheetRunRate rate2 = TestAgeBalanceSheetRunRateFinder.findOne(op); assertNotNull(rate2); assertTrue(rate2.isPriceNull()); assertTrue(rate2.isValueNull()); }
Example #3
Source File: TestDatedNonAudited.java From reladomo with Apache License 2.0 | 6 votes |
public void testUpdatePropagation() throws Exception { MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { @Override public Object executeTransaction(MithraTransaction tx) throws Throwable { Timestamp future = new Timestamp(timestampFormat.parse("2013-01-20 00:00:00").getTime()); Timestamp past = new Timestamp(timestampFormat.parse("2011-01-20 00:00:00").getTime()); Timestamp now = new Timestamp(timestampFormat.parse("2012-01-20 00:00:00").getTime()); NonAuditedBalanceInterface balPast = buildNonAuditedBalance(past); balPast.setAcmapCode("A"); balPast.setBalanceId(2000); balPast.setQuantity(-6851); balPast.insert(); NonAuditedBalanceInterface balAtFuture = findNonAuditedBalanceForBusinessDate(2000, future); assertEquals(-6851.0, balAtFuture.getQuantity(), 0.01); NonAuditedBalanceInterface balNow = findNonAuditedBalanceForBusinessDate(2000, now); assertEquals(-6851.0, balNow.getQuantity(), 0.01); balNow.setQuantity(100); assertEquals(100.0, balNow.getQuantity(), 0.01); assertEquals(100.0, balAtFuture.getQuantity(), 0.01); return null; } }, new TransactionStyle(10000)); }
Example #4
Source File: TestIsNullOrLargeInOperation.java From reladomo with Apache License 2.0 | 6 votes |
private void createAddress(final String city, final String state) { MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { @Override public Object executeTransaction(MithraTransaction tx) throws Throwable { Address address = new Address(DefaultInfinityTimestamp.getDefaultInfinity()); address.setCity(city); if(state != null) address.setState(state); address.setAddressId(addressId++); address.setChangedBy("testusr"); address.insert(); return null; } }); }
Example #5
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType3Update() { final EvoTypesRoot root = this.createEvoTypesRoot('B', false, (byte) 1, "update"); assertNull(EvoType3TxnTypesBFinder.findOneBypassCache(EvoType3TxnTypesBFinder.rootEvo().eq(root))); final EvoType3TxnTypesB newTypes = EvoType3TxnTypesBFinder.findOneBypassCache( EvoType3TxnTypesBFinder.pk().charAttribute().eq('B').and( EvoType3TxnTypesBFinder.pk().booleanAttribute().eq(false))); assertNotNull(newTypes); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { newTypes.copyRootEvo(root); return null; } }); assertNotNull(EvoType3TxnTypesBFinder.findOne(EvoType3TxnTypesBFinder.rootEvo().eq(root))); assertNotNull(EvoType3TxnTypesBFinder.findOneBypassCache(EvoType3TxnTypesBFinder.rootEvo().eq(root))); }
Example #6
Source File: AbstractDatedCache.java From reladomo with Apache License 2.0 | 6 votes |
private boolean getManyFromUniqueSequential(Extractor[] extractors, boolean abortIfNotFound, Timestamp[] asOfDates, MithraTransaction tx, FastList results, Iterator dataHolders, DatedSemiUniqueDataIndex uniqueIndex) { CommonExtractorBasedHashingStrategy hashStrategy = uniqueIndex.getNonDatedPkHashStrategy(); while(dataHolders.hasNext()) { Object dataHolder = dataHolders.next(); populateAsOfDates(extractors, dataHolder, asOfDates); MithraDataObject data = (MithraDataObject) uniqueIndex.getSemiUniqueAsOneWithDates(dataHolder, extractors, asOfDates, hashStrategy.computeHashCode(dataHolder, extractors)); if (data != null) { MithraDatedObject businessObject = this.getBusinessObjectFromData(data, asOfDates, getNonDatedPkHashCode(data), false, tx, true); if (businessObject == null) { return true; } results.add(businessObject); } else { if (abortIfNotFound) return true; } } return false; }
Example #7
Source File: TestCopyTransactionalObjectAttributes.java From reladomo with Apache License 2.0 | 6 votes |
public void testCopyNonPrimaryKeyAttributesFromInMemoryObjectInTx2() throws Exception { MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); Order newOrder = new Order(); newOrder.setOrderDate(new Timestamp(System.currentTimeMillis())); newOrder.setState("NEW"); newOrder.setDescription("New Order"); newOrder.setTrackingId("Tracking Id"); newOrder.setUserId(9876); newOrder.setOrderId(1); Order order = OrderFinder.findOne(OrderFinder.orderId().eq(1)); order.copyNonPrimaryKeyAttributesFrom(newOrder); tx.commit(); assertTrue(compareOrderNonPrimaryKeyAttributes(order, newOrder)); }
Example #8
Source File: TestMariaGeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void xtestDeadConnectionInTransaction() throws Exception { final Order order = OrderFinder.findOne(OrderFinder.orderId().eq(1)); // put a break point on the next line, and kill the connection System.out.println("kill the connection now!"); MithraManager.getInstance().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { order.getItems().forceResolve(); // for a second test, put a break point on the next line and kill the connection order.getOrderStatus(); return null; } }); }
Example #9
Source File: TransactionalNonUniqueIndex.java From reladomo with Apache License 2.0 | 6 votes |
@Override public void prepareForReindexInTransaction(Object businessObject, MithraTransaction tx) { TransactionLocalStorage txStorage = (TransactionLocalStorage) perTransactionStorage.get(tx); NonUniqueIndex threadIndex = getAddedFromLocalStorage(txStorage); if (threadIndex != null && threadIndex.contains(businessObject)) { threadIndex.remove(businessObject); } else { if (threadIndex == null) { txStorage = createPerThreadAddedIndex(tx, txStorage); } FullUniqueIndex deletedIndex = txStorage.deleted; if (deletedIndex == null) { deletedIndex = this.createPerThreadDeletedIndex(tx, txStorage); } deletedIndex.put(this.nonTransactionalUnderlyingObjectGetter.getUnderlyingObject(businessObject)); } }
Example #10
Source File: TestTransactionalClientPortal.java From reladomo with Apache License 2.0 | 6 votes |
public void testCount() { OrderList list = new OrderList(OrderFinder.state().eq("In-Progress")); int count = list.count(); assertEquals(count, list.size()); MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); Order order = new Order(); int orderId = 1017; order.setOrderId(orderId); Timestamp orderDate = new Timestamp(INITIAL_TIME); order.setOrderDate(orderDate); order.setUserIdNull(); String description = "new order description"; order.setDescription(description); order.setTrackingId("T1"); order.setState("In-Progress"); order.insert(); list = new OrderList(OrderFinder.state().eq("In-Progress")); assertEquals(count+1, list.count()); tx.commit(); }
Example #11
Source File: TestPostgresGeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void xtestDeadConnectionInTransaction() throws Exception { final Order order = OrderFinder.findOne(OrderFinder.orderId().eq(1)); // put a break point on the next line, and kill the connection System.out.println("kill the connection now!"); MithraManager.getInstance().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { order.getItems().forceResolve(); // for a second test, put a break point on the next line and kill the connection order.getOrderStatus(); return null; } }); }
Example #12
Source File: TransactionalNonUniqueIndex.java From reladomo with Apache License 2.0 | 6 votes |
public Object put(Object businessObject) { MithraTransaction tx = MithraManagerProvider.getMithraManager().zGetCurrentTransactionWithNoCheck(); if (tx != null) { TransactionLocalStorage txStorage = (TransactionLocalStorage) perTransactionStorage.get(tx); NonUniqueIndex perThreadIndex = getAddedFromLocalStorage(txStorage); if (perThreadIndex == null) { perThreadIndex = this.createPerThreadAddedIndex(tx, txStorage).added; } return perThreadIndex.put(businessObject); } else { return this.nonTransactionalPut(businessObject); } }
Example #13
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType2DatedIncrementUntil() { Operation op = EvoType2DatedTxnTypesBFinder.pk().charAttribute().eq('B').and( EvoType2DatedTxnTypesBFinder.pk().booleanAttribute().eq(false)).and( EvoType2DatedTxnTypesBFinder.businessDate().eq(Timestamp.valueOf("2007-09-10 00:00:00.0"))); final EvoType2DatedTxnTypesB types = EvoType2DatedTxnTypesBFinder.findOneBypassCache(op); assertEquals(1.1d, types.getRootEvo().getDoubleAttribute()); final Timestamp newBusinessDateEnd = Timestamp.valueOf("2007-09-12 18:30:00.0"); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { types.getRootEvo().incrementDoubleAttributeUntil(6.0d, newBusinessDateEnd); return null; } }); assertEquals(7.1d, EvoType2DatedTxnTypesBFinder.findOne(op).getRootEvo().getDoubleAttribute()); assertEquals(newBusinessDateEnd, EvoType2DatedTxnTypesBFinder.findOne(op).getBusinessDateTo()); assertEquals(7.1d, EvoType2DatedTxnTypesBFinder.findOneBypassCache(op).getRootEvo().getDoubleAttribute()); assertEquals(newBusinessDateEnd, EvoType2DatedTxnTypesBFinder.findOneBypassCache(op).getBusinessDateTo()); }
Example #14
Source File: TestPureObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType2BatchDelete() { final PureType2TxnTypesAList typesList = PureType2TxnTypesAFinder.findMany(PureType2TxnTypesAFinder.all()); assertEquals(2, typesList.size()); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { for (PureType2TxnTypesA types : typesList) { types.delete(); } return null; } }); assertEquals(0, PureType2TxnTypesAFinder.findMany(PureType2TxnTypesAFinder.all()).size()); assertEquals(0, PureType2TxnTypesAFinder.findManyBypassCache(PureType2TxnTypesAFinder.all()).size()); }
Example #15
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType2DatedUpdateUntil() { final Timestamp businessDate = Timestamp.valueOf("2007-09-10 00:00:00.0"); final EvoTypesRoot root = this.createEvoTypesRoot('B', false, (byte) 1, "update"); Operation op = EvoType2DatedTxnTypesBFinder.rootEvo().eq(root).and(EvoType2DatedTxnTypesBFinder.businessDate().eq(businessDate)); assertNull(EvoType2DatedTxnTypesBFinder.findOneBypassCache(op)); final EvoType2DatedTxnTypesB types = EvoType2DatedTxnTypesBFinder.findOneBypassCache( EvoType2DatedTxnTypesBFinder.pk().charAttribute().eq('B').and( EvoType2DatedTxnTypesBFinder.pk().booleanAttribute().eq(false)).and( EvoType2DatedTxnTypesBFinder.businessDate().eq(businessDate))); assertNotNull(types); final Timestamp newBusinessDateEnd = Timestamp.valueOf("2007-09-12 18:30:00.0"); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { types.copyRootEvoUntil(root, newBusinessDateEnd); return null; } }); assertEquals(newBusinessDateEnd, EvoType2DatedTxnTypesBFinder.findOne(op).getBusinessDateTo()); assertEquals(newBusinessDateEnd, EvoType2DatedTxnTypesBFinder.findOneBypassCache(op).getBusinessDateTo()); }
Example #16
Source File: TestForceRefresh.java From reladomo with Apache License 2.0 | 6 votes |
public void testForceRefreshSingleDatedMultiPkListInTx() throws SQLException { Operation op = TestEodAcctIfPnlFinder.userId().eq("moh"); op = op.and(TestEodAcctIfPnlFinder.processingDate().eq(createNowTimestamp())); TestEodAcctIfPnlList list = new TestEodAcctIfPnlList(op); list.forceResolve(); assertTrue(list.size() > 1); final TestEodAcctIfPnlList list2 = new TestEodAcctIfPnlList(); list2.addAll(list); int count = this.getRetrievalCount(); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { list2.forceRefresh(); return null; } }); assertEquals(count+1, this.getRetrievalCount()); }
Example #17
Source File: TestOracleGeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void testBulkInsert() { final int initialId = 10000; final int listSize = 20; MithraManagerProvider.getMithraManager().executeTransactionalCommand( new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { ProductList productList = createNewProductList(initialId, listSize); productList.insertAll(); tx.setBulkInsertThreshold(10); return null; } } ); Operation op = ProductFinder.productId().greaterThanEquals(initialId); ProductList list = new ProductList(op); assertEquals(listSize, list.size()); }
Example #18
Source File: AbstractNonDatedCache.java From reladomo with Apache License 2.0 | 6 votes |
public void reloadDirty(MithraTransaction tx) { InternalList dirtyDataList = (InternalList) this.markedDirtyForReload.get(tx); if (dirtyDataList != null) { if (this.isPartialCache()) { for (int i = 0; i < dirtyDataList.size(); i++) { this.markDirty((MithraDataObject) dirtyDataList.get(i)); } } else { // this.portal.getMithraObjectPersister().refresh(, false) throw new RuntimeException("optimistic lock failure not supported with full cache"); } dirtyDataList.clear(); } }
Example #19
Source File: TestSybaseTimeTests.java From reladomo with Apache License 2.0 | 6 votes |
public void testBitemporalInsertUntil() { Operation businessDate = AlarmBitemporalTransactionalFinder.businessDate().eq(Timestamp.valueOf("2012-01-01 23:59:00.0")); final AlarmBitemporalTransactionalList alarms = new AlarmBitemporalTransactionalList(businessDate); alarms.addOrderBy(AlarmBitemporalTransactionalFinder.id().ascendingOrderBy()); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { @Override public Object executeTransaction(MithraTransaction tx) throws Throwable { AlarmBitemporalTransactional insertAlarm = new AlarmBitemporalTransactional(Timestamp.valueOf("2012-01-01 23:59:00.0")); insertAlarm.setTime(Time.withMillis(1, 1, 1, 1)); insertAlarm.setId(200); insertAlarm.insertUntil(Timestamp.valueOf("2013-01-01 23:59:00.0")); return null; } }); assertNotNull(AlarmBitemporalTransactionalFinder.findOne(AlarmBitemporalTransactionalFinder.businessDate().eq(Timestamp.valueOf("2012-12-12 23:59:00.0")).and(AlarmBitemporalTransactionalFinder.time().eq(Time.withMillis(1, 1, 1, 1))))); Operation op = AlarmBitemporalTransactionalFinder.businessDate().eq(new Timestamp(System.currentTimeMillis())).and(AlarmBitemporalTransactionalFinder.time().eq(Time.withMillis(1, 1, 1, 1))); assertNull(AlarmBitemporalTransactionalFinder.findOne(op)); }
Example #20
Source File: TestMariaGeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void testMultipleUpdatesToSameObjectInTransaction() { int id = 9876; final Operation op = AllTypesFinder.id().eq(id); MithraManagerProvider.getMithraManager().executeTransactionalCommand( new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { AllTypes allTypes = AllTypesFinder.findOne(op); allTypes.setIntValue(100); allTypes.setNullableBooleanValue(true); allTypes.setNullableByteValue((byte) 10); allTypes.setNullableCharValue('a'); allTypes.setNullableShortValue((short) 1000); allTypes.setNullableIntValue(987654); return null; } } ); String sql = "select " + getAllTypesColumns() + " from mithra.ALL_TYPES where ID = " + 9876; validateMithraResult(op, sql); }
Example #21
Source File: TestDatedDetached.java From reladomo with Apache License 2.0 | 6 votes |
public void testIsDeletedOrMarkForDeletionInTx() throws ParseException { Timestamp businessDate = new Timestamp(timestampFormat.parse("2006-01-01 00:00:00").getTime()); MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); BitemporalOrder order1 = new BitemporalOrder(businessDate); order1.setOrderId(987); order1.setState("Created"); order1.setUserId(123); order1.setOrderDate(new Timestamp(System.currentTimeMillis())); assertFalse(order1.isDeletedOrMarkForDeletion()); order1.insert(); assertFalse(order1.isDeletedOrMarkForDeletion()); tx.commit(); tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); order1.terminate(); assertTrue(order1.isDeletedOrMarkForDeletion()); tx.commit(); }
Example #22
Source File: TestTransactionalList.java From reladomo with Apache License 2.0 | 6 votes |
public void testPurgeAllAuditOnly() { AuditOnlyBalanceList auditOnlyList = this.getPurgeAllAuditOnlyList(2); assertTrue(auditOnlyList.size() > 0); //begin transaction MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); auditOnlyList = this.getPurgeAllAuditOnlyList(2); auditOnlyList.purgeAll(); AuditOnlyBalanceList auditOnlyListCheck = this.getPurgeAllAuditOnlyList(2); assertEquals(0, auditOnlyListCheck.size()); tx.commit(); //end transaction auditOnlyListCheck = this.getPurgeAllAuditOnlyList(2); assertEquals(0, auditOnlyListCheck.size()); }
Example #23
Source File: CommonVendorTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void testOptimisticLocking() { final TestEodAcctIfPnlList list = TestEodAcctIfPnlFinder.findMany(TestEodAcctIfPnlFinder.all()); int size = list.size(); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { @Override public Object executeTransaction(MithraTransaction tx) throws Throwable { TestEodAcctIfPnlFinder.setTransactionModeReadCacheWithOptimisticLocking(tx); for(TestEodAcctIfPnl pnl: list) { pnl.setUserId("fred"); } return null; } }); assertEquals(size, TestEodAcctIfPnlFinder.findMany(TestEodAcctIfPnlFinder.userId().eq("fred")).size()); }
Example #24
Source File: TestDb2GeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void testBulkInsert() { final int initialId = 10000; final int listSize = 20; MithraManagerProvider.getMithraManager().executeTransactionalCommand( new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { ProductList productList = createNewProductList(initialId, listSize); productList.insertAll(); tx.setBulkInsertThreshold(10); return null; } } ); Operation op = ProductFinder.productId().greaterThanEquals(initialId); ProductList list = new ProductList(op); assertEquals(listSize, list.size()); }
Example #25
Source File: TestDatedAuditOnly.java From reladomo with Apache License 2.0 | 5 votes |
public void testInsertAll() throws SQLException { MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); try { AuditOnlyBalanceList list = new AuditOnlyBalanceList(); for(int i=0;i<30;i++) { AuditOnlyBalance tb = new AuditOnlyBalance(InfinityTimestamp.getParaInfinity()); tb.setAcmapCode("A"); tb.setBalanceId(2000+i); tb.setQuantity(12.5+i); tb.setInterest(22.1+i); list.add(tb); } list.insertAll(); tx.commit(); } catch(Throwable t) { getLogger().error("transaction failed", t); tx.rollback(); fail("transaction failed see exception"); } for(int i=0;i<30;i++) { this.checker.checkDatedAuditOnlyInfinityRow(2000+i, 12.5+i, 22.1+i); } }
Example #26
Source File: DatedDetachedTxEnrollBehavior.java From reladomo with Apache License 2.0 | 5 votes |
public DatedTransactionalBehavior enrollInTransactionForWrite(MithraDatedTransactionalObject mto, MithraTransaction tx, DatedTransactionalState prevState, int persistenceState) { MithraDataObject data = mto.zGetCurrentData(); if (data == null) data = mto.zAllocateData(); else data = data.copy(); if (mto.zEnrollInTransactionForWrite(prevState, null, data, tx)) { return AbstractDatedTransactionalBehavior.getDetachedSameTxBehavior(); } return null; }
Example #27
Source File: TestParaDatedBitemporal.java From reladomo with Apache License 2.0 | 5 votes |
private ParaBalance insertParaBalance(Timestamp businessDate, ParaBalance paraBalance, int balanceId) { MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); try { paraBalance = new ParaBalance(businessDate, InfinityTimestamp.getParaInfinity()); paraBalance.setAcmapCode("A"); paraBalance.setBalanceId(balanceId); assertEquals(balanceId, paraBalance.getBalanceId()); paraBalance.setQuantity(7.9); paraBalance.insert(); assertTrue(paraBalance.zIsParticipatingInTransaction(tx)); int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); ParaBalance fromCache = ParaBalanceFinder.findOne(ParaBalanceFinder.acmapCode().eq("A") .and(ParaBalanceFinder.balanceId().eq(balanceId)) .and(ParaBalanceFinder.businessDate().eq(businessDate))); assertSame(paraBalance, fromCache); fromCache = ParaBalanceFinder.findOne(ParaBalanceFinder.acmapCode().eq("A") .and(ParaBalanceFinder.balanceId().eq(balanceId)) .and(ParaBalanceFinder.businessDate().eq(new Timestamp(businessDate.getTime()+1000)))); assertNotSame(paraBalance, fromCache); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); tx.commit(); Thread.sleep(50); // just so the next processing time will be later } catch(Throwable t) { getLogger().error("transaction failed", t); tx.rollback(); fail("transaction failed see exception"); } return paraBalance; }
Example #28
Source File: TestAdhocDeepFetch.java From reladomo with Apache License 2.0 | 5 votes |
public void testOneToOneManyToOneManyToManySameAttributeInTx() { MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { public Object executeTransaction(MithraTransaction tx) throws Throwable { testOneToOneManyToOneManyToManySameAttribute(); return null; } }); }
Example #29
Source File: TestComplexPKUpdate.java From reladomo with Apache License 2.0 | 5 votes |
public void testInsertMutablePkWithTx() throws SQLException { final String currency = "EUR"; final int sourceId = 100; final Timestamp time = new Timestamp(System.currentTimeMillis()); Operation op = getOp(currency, sourceId, time); assertNull(ExchangeRateFinder.findOne(op)); final ExchangeRate exchangeRate = new ExchangeRate(); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { exchangeRate.setAcmapCode(SOURCE_A); exchangeRate.setCurrency(currency); exchangeRate.setSource(sourceId); exchangeRate.setDate(time); exchangeRate.setExchangeRate(2); exchangeRate.insert(); return null; } }); checkExchangeRate(2, currency, sourceId, time); int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); assertSame(exchangeRate, ExchangeRateFinder.findOne(op)); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); }
Example #30
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 5 votes |
public void testType1DatedIncrement() { final BigDecimal value1= new BigDecimal("144444444444444.444"); final BigDecimal value2= new BigDecimal("244444444444444.444"); final BigDecimal value3= new BigDecimal("34444444.44"); Operation op = EvoType1DatedTxnTypesFinder.pk().charAttribute().eq('B').and( EvoType1DatedTxnTypesFinder.pk().booleanAttribute().eq(false)).and( EvoType1DatedTxnTypesFinder.businessDate().eq(Timestamp.valueOf("2007-09-10 00:00:00.0"))); final EvoType1DatedTxnTypes types = EvoType1DatedTxnTypesFinder.findOneBypassCache(op); assertEquals(1.1d, types.getRootEvo().getDoubleAttribute()); assertEquals(value1, types.getRootEvo().getBigDecimalAttribute()); assertEquals(value2, types.getRootEvo().getNestedEvo().getBigDecimalAttribute()); assertEquals(value3, types.getRootEvo().getNestedEvo().getLeafEvo().getBigDecimalAttribute()); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { types.getRootEvo().incrementDoubleAttribute(6.0d); types.getRootEvo().incrementBigDecimalAttribute(value1); types.getRootEvo().getNestedEvo().incrementBigDecimalAttribute(value2); types.getRootEvo().getNestedEvo().getLeafEvo().incrementBigDecimalAttribute(value3); return null; } }); BigDecimal incrementedValue1 = new BigDecimal("288888888888888.888"); BigDecimal incrementedValue2 = new BigDecimal("488888888888888.888"); BigDecimal incrementedValue3 = new BigDecimal("68888888.88"); assertEquals(7.1d, EvoType1DatedTxnTypesFinder.findOne(op).getRootEvo().getDoubleAttribute()); assertEquals(7.1d, EvoType1DatedTxnTypesFinder.findOneBypassCache(op).getRootEvo().getDoubleAttribute()); assertEquals(incrementedValue1, EvoType1DatedTxnTypesFinder.findOne(op).getRootEvo().getBigDecimalAttribute()); assertEquals(incrementedValue1, EvoType1DatedTxnTypesFinder.findOneBypassCache(op).getRootEvo().getBigDecimalAttribute()); assertEquals(incrementedValue2, EvoType1DatedTxnTypesFinder.findOne(op).getRootEvo().getNestedEvo().getBigDecimalAttribute()); assertEquals(incrementedValue2, EvoType1DatedTxnTypesFinder.findOneBypassCache(op).getRootEvo().getNestedEvo().getBigDecimalAttribute()); assertEquals(incrementedValue3, EvoType1DatedTxnTypesFinder.findOne(op).getRootEvo().getNestedEvo().getLeafEvo().getBigDecimalAttribute()); assertEquals(incrementedValue3, EvoType1DatedTxnTypesFinder.findOneBypassCache(op).getRootEvo().getNestedEvo().getLeafEvo().getBigDecimalAttribute()); }