com.gs.fw.common.mithra.MithraManagerProvider Java Examples
The following examples show how to use
com.gs.fw.common.mithra.MithraManagerProvider.
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: MithraConfigurationManager.java From reladomo with Apache License 2.0 | 6 votes |
public MithraObjectPortal initializePortal(String className) { List<String> errors = new ArrayList<String>(); final MithraObjectPortal portal = this.initializeObject(className, errors); checkForErrors(errors); if (portal != null) { if (MithraManagerProvider.getMithraManager().isInTransaction()) { ExceptionCatchingThread.executeTask(new ExceptionHandlingTask() { @Override public void execute() { portal.loadCache(); } }); } else { portal.loadCache(); } } return portal; }
Example #2
Source File: TestTransactionalClientPortal.java From reladomo with Apache License 2.0 | 6 votes |
public void testInsert() throws ParseException { 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.insert(); int retrieveCount = MithraManagerProvider.getMithraManager().getRemoteRetrieveCount(); Order order2 = OrderFinder.findOne(OrderFinder.orderId().eq(orderId)); assertSame(order, order2); assertEquals(retrieveCount, MithraManagerProvider.getMithraManager().getRemoteRetrieveCount()); OrderList list = new OrderList(OrderFinder.orderId().greaterThanEquals(orderId).and(OrderFinder.orderId().lessThan(1018))); assertEquals(1, list.size()); assertSame(order, list.getOrderAt(0)); String serverdesc = (String) this.getRemoteWorkerVm().executeMethod("serverTestInsert"); assertEquals("new order description", serverdesc); this.getRemoteWorkerVm().executeMethod("serverTestInsertInDatabase"); }
Example #3
Source File: AbstractDatedTransactionalCache.java From reladomo with Apache License 2.0 | 6 votes |
@Override public void getManyDatedObjectsFromData(Object[] dataArray, int length, ObjectWithMapperStack[] asOfOpWithStacks) { MithraTransaction tx = MithraManagerProvider.getMithraManager().getCurrentTransaction(); if (tx == null) { super.getManyDatedObjectsFromData(dataArray, length, asOfOpWithStacks); } else { Timestamp[] asOfDates = this.getTempTimestamps(); for(int i=0;i<length;i++) { MithraDataObject data = (MithraDataObject) dataArray[i]; for(int a=0;a<asOfOpWithStacks.length;a++) { AsOfOperation asOfOperation = (AsOfOperation) asOfOpWithStacks[a].getObject(); asOfDates[a] = asOfOperation.inflateAsOfDate(data); } dataArray[i] = getObjectFromDataForTx(data, asOfDates, tx, false); } } }
Example #4
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType1DatedUpdate() { final Timestamp businessDate = Timestamp.valueOf("2007-09-10 00:00:00.0"); final EvoTypesRoot root = this.createEvoTypesRoot('B', false, (byte) 1, "update"); Operation op = EvoType1DatedTxnTypesFinder.rootEvo().eq(root).and(EvoType1DatedTxnTypesFinder.businessDate().eq(businessDate)); assertNull(EvoType1DatedTxnTypesFinder.findOneBypassCache(op)); final EvoType1DatedTxnTypes types = EvoType1DatedTxnTypesFinder.findOneBypassCache( EvoType1DatedTxnTypesFinder.pk().charAttribute().eq('B').and( EvoType1DatedTxnTypesFinder.pk().booleanAttribute().eq(false)).and( EvoType1DatedTxnTypesFinder.businessDate().eq(businessDate))); assertNotNull(types); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { types.copyRootEvo(root); return null; } }); assertNotNull(EvoType1DatedTxnTypesFinder.findOne(op)); assertNotNull(EvoType1DatedTxnTypesFinder.findOneBypassCache(op)); }
Example #5
Source File: TestMultiClientNotificationTestCase.java From reladomo with Apache License 2.0 | 6 votes |
public void remoteInsertOrderItem(int orderItemId, int orderId, boolean inTransaction) { MithraTransaction tx = null; if(inTransaction) { tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); } OrderItem item = new OrderItem(); item.setId(orderItemId); item.setOrderId(orderId); item.insert(); if(inTransaction) { tx.commit(); } }
Example #6
Source File: TestTransactionalObject.java From reladomo with Apache License 2.0 | 6 votes |
public void testReloadInTxCacheInsert() throws SQLException { if (OrderFinder.getMithraObjectPortal().getCache().isFullCache()) { int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); int orderId = 5555; Timestamp orderDate = new Timestamp(System.currentTimeMillis()); Order order = OrderFinder.findOne(OrderFinder.orderId().eq(orderId)); assertNull(order); jdbcInsertNewOrder(orderDate); reloadInTx(); order = OrderFinder.findOne(OrderFinder.orderId().eq(orderId)); assertNotNull(order); assertEquals(orderId, order.getOrderId()); assertEquals(orderDate, order.getOrderDate()); assertEquals(2222, order.getUserId()); assertEquals("test desc", order.getDescription()); assertEquals("teststate", order.getState()); assertEquals("testid", order.getTrackingId()); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); } }
Example #7
Source File: TestComplexPKUpdate.java From reladomo with Apache License 2.0 | 6 votes |
public void testInsertMutablePkWithoutTx() throws SQLException { String currency = "EUR"; int sourceId = 100; Timestamp time = new Timestamp(System.currentTimeMillis()); Operation op = getOp(currency, sourceId, time); ExchangeRate exchangeRate = ExchangeRateFinder.findOne(op); assertNull(exchangeRate); exchangeRate = new ExchangeRate(); exchangeRate.setAcmapCode(SOURCE_A); exchangeRate.setCurrency(currency); exchangeRate.setSource(sourceId); exchangeRate.setDate(time); exchangeRate.setExchangeRate(2); exchangeRate.insert(); checkExchangeRate(2, currency, sourceId, time); int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); assertSame(exchangeRate, ExchangeRateFinder.findOne(op)); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); }
Example #8
Source File: TestTimeBitemporalTransactional.java From reladomo with Apache License 2.0 | 6 votes |
public void testUpdateUntil() { 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 { alarms.get(0).setTimeUntil(Time.withMillis(1, 2, 3, 3), Timestamp.valueOf("2013-01-01 23:59:00.0")); return null; } }); assertEquals(Time.withMillis(1, 2, 3, 3), AlarmBitemporalTransactionalFinder.findOne(AlarmBitemporalTransactionalFinder.businessDate().eq(Timestamp.valueOf("2012-12-12 23:59:00.0")).and(AlarmBitemporalTransactionalFinder.id().eq(1))).getTime()); Operation op = AlarmBitemporalTransactionalFinder.businessDate().eq(new Timestamp(System.currentTimeMillis())).and(AlarmBitemporalTransactionalFinder.id().eq(1)); assertEquals(Time.withMillis(10, 30, 59, 11), AlarmBitemporalTransactionalFinder.findOne(op).getTime()); }
Example #9
Source File: TestTransactionalClientPortal.java From reladomo with Apache License 2.0 | 6 votes |
public void testBatchDelete() { MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); OrderList list = new OrderList(OrderFinder.userId().eq(1)); assertTrue(list.size() > 1); Order[] elements = list.elements(); for(int i=0;i<elements.length;i++) { elements[i].delete(); } OrderList list2 = new OrderList(OrderFinder.userId().eq(1)); assertEquals(0, list2.size()); tx.commit(); list2 = new OrderList(OrderFinder.userId().eq(1)); assertEquals(0, list2.size()); this.getRemoteWorkerVm().executeMethod("serverTestBatchDeleteInCache"); this.getRemoteWorkerVm().executeMethod("serverTestBatchDeleteInDatabase"); }
Example #10
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType2DatedUpdate() { 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); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { types.copyRootEvo(root); return null; } }); assertNotNull(EvoType2DatedTxnTypesBFinder.findOne(op)); assertNotNull(EvoType2DatedTxnTypesBFinder.findOneBypassCache(op)); }
Example #11
Source File: TestTransactionalObject.java From reladomo with Apache License 2.0 | 6 votes |
public void testInsertAndFindInTransaction() throws SQLException { int userId = 17111; MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); Order order = new Order(); int orderId = 1017; order.setOrderId(orderId); OrderFinder.findOne(OrderFinder.userId().eq(userId)); // causes the tx to flush after we've enrolled this object Timestamp orderDate = new Timestamp(System.currentTimeMillis()); order.setOrderDate(orderDate); String description = "new order description"; order.setDescription(description); order.setUserId(userId); order.insert(); assertSame(order, OrderFinder.findOne(OrderFinder.userId().eq(userId))); tx.commit(); assertNotNull(order); checkUserId(userId, orderId); }
Example #12
Source File: TestEmbeddedValueObjects.java From reladomo with Apache License 2.0 | 6 votes |
public void testType3Insert() { EvoTypesLeaf pk = createEvoTypesLeaf('A', true, (byte) 1, "insert"); Operation op = EvoType3TxnTypesAFinder.pk().eq(pk); assertNull(EvoType3TxnTypesAFinder.findOneBypassCache(op)); final EvoType3TxnTypes types = new EvoType3TxnTypesA(); types.copyPk(pk); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { types.insert(); return null; } }); // assertNotNull(EvoType3TxnTypesAFinder.findOne(op)); assertNotNull(EvoType3TxnTypesAFinder.findOneBypassCache(op)); }
Example #13
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 #14
Source File: TestAdhocDeepFetch.java From reladomo with Apache License 2.0 | 6 votes |
public void testOneToOneWithSourceWithTemp() { Timestamp now = new Timestamp(System.currentTimeMillis()); Operation op = TinyBalanceFinder.balanceId().lessThan(100); op = op.and(TinyBalanceFinder.businessDate().eq(now)); op = op.and(TinyBalanceFinder.acmapCode().eq(SOURCE_A)); TinyBalanceList list = new TinyBalanceList(TinyBalanceFinder.findMany(op)); for(int i=0;i<1000;i++) { TinyBalance tb = new TinyBalance(now); tb.setAcmapCode(SOURCE_A); tb.setBalanceId(i+10000); tb.setQuantity(i*7); list.add(tb); } list.deepFetch(TinyBalanceFinder.testRelationship()); assertTrue(list.size() > 0); int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); int related = 0; for(int i=0;i<list.size();i++) { if (list.get(i).getTestRelationship() != null) related++; } assertTrue(related > 0); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); }
Example #15
Source File: Exercise2Test.java From reladomo-kata with Apache License 2.0 | 6 votes |
/** * The relationship is one {@link kata.domain.Person} to many {@link kata.domain.Pet}s, many {@link kata.domain.Pet}s to one {@link PetType}. * Since there are three relationships the minimum database hits are 3. * Use appropriate method on {@link kata.domain.PersonFinder} and Reladomo's {@code deepFetch} property. * * @see PersonList#deepFetch(Navigation) */ @Test public void getAllObjectsInMinDatabaseHits() { int minDatabaseHits = 3; PersonList people = null; Verify.assertSize(8, people); int databaseHitsAfterPeopleFetch = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); for (int i = 0; i < people.size(); i++) { PetList pets = people.getPersonAt(i).getPets(); int databaseHitsAfterPetFetch = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); Assert.assertEquals(databaseHitsAfterPeopleFetch, databaseHitsAfterPetFetch); for (int j = 0; j < pets.size(); j++) { PetType petType = pets.getPetAt(j).getPetType(); int databaseHitsAfterPetTypeFetch = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); Assert.assertEquals(databaseHitsAfterPetFetch, databaseHitsAfterPetTypeFetch); } } }
Example #16
Source File: TransactionalDatedNonUniqueIndex.java From reladomo with Apache License 2.0 | 6 votes |
public boolean contains(Object keyHolder, Extractor[] extractors, Filter2 filter) // for multi attribute indicies { TransactionLocalStorage txStorage = (TransactionLocalStorage) perTransactionStorage.get(MithraManagerProvider.getMithraManager().zGetCurrentTransactionWithNoCheck()); if (this.getLocalStorageDeleted(txStorage) != null) { Object candidate = this.get(keyHolder, extractors); return candidate != null && (filter == null || filter.matches(candidate, keyHolder)); } Index perThreadAdded = getLocalStorageAdded(txStorage); if (perThreadAdded != null) { return perThreadAdded.contains(keyHolder, extractors, filter); } return this.mainIndex.contains(keyHolder, extractors, filter); }
Example #17
Source File: TestSybaseGeneralTestCases.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: 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 #19
Source File: TestTransactionalObject.java From reladomo with Apache License 2.0 | 6 votes |
public void testInClauseCausesFlushMany() { MithraManagerProvider.getMithraManager().executeTransactionalCommand( new TransactionalCommand() { public Object executeTransaction(MithraTransaction tran) throws Throwable { Order order = new Order(); order.setOrderId(1000); order.setState("x"); order.setUserId(1); order.setOrderDate(new Timestamp(System.currentTimeMillis())); order.setDescription("t"); order.insert(); IntHashSet set = new IntHashSet(); set.add(1); set.add(1000); set.add(1001); assertEquals(2, OrderFinder.findMany(OrderFinder.orderId().in(set)).size()); return null; } }); }
Example #20
Source File: TestTransactionalClientPortal.java From reladomo with Apache License 2.0 | 6 votes |
public void testBatchInsert() { MithraTransaction tx = MithraManagerProvider.getMithraManager().startOrContinueTransaction(); for(int i=1017;i<2000;i++) { Order order = new Order(); int orderId = i; order.setOrderId(orderId); Timestamp orderDate = new Timestamp(INITIAL_TIME+i); order.setOrderDate(orderDate); order.setUserIdNull(); String description = "description "+i; order.setDescription(description); order.setTrackingId("T"+i); order.insert(); } tx.commit(); this.getRemoteWorkerVm().executeMethod("serverTestBatchInsertInCache"); this.getRemoteWorkerVm().executeMethod("serverTestBatchInsertInDatabase"); }
Example #21
Source File: TestAuditOnlyRelationshipPersistence.java From reladomo with Apache License 2.0 | 6 votes |
public void testPersistedAuditedOrderCascadeTerminate() { final AuditedOrder order = findOne(1); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { order.cascadeTerminate(); return null; } }); AuditedOrderItemList list = new AuditedOrderItemList(AuditedOrderItemFinder.orderId().eq(1)); list.setBypassCache(true); assertEquals(0, list.size()); assertNull(AuditedOrderStatusFinder.findOne(AuditedOrderStatusFinder.orderId().eq(1))); }
Example #22
Source File: TestSybaseGeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void testBigDecimalUpdate() { final BigOrder order2 = findOrder(100); final BigDecimal discount = new BigDecimal("0.980"); assertEquals(new BigDecimal("0.010"), order2.getDiscountPercentage()); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { order2.setUserId(2); order2.setDiscountPercentage(discount); return null; } }); BigOrder order3 = findOrder(100); assertEquals(discount, order3.getDiscountPercentage()); }
Example #23
Source File: TestBasicRetrieval.java From reladomo with Apache License 2.0 | 6 votes |
public void testBypassCacheOnList() throws SQLException { String directSql = "select * from TRIAL where TRIAL_ID in ('001A', '001B')"; HashSet trialSet = new HashSet(); trialSet.add("001A"); trialSet.add("001B"); TrialList trialList = new TrialList(TrialFinder.trialId().in(trialSet)); this.genericRetrievalTest(directSql, trialList, false); TrialList trialList2 = new TrialList(TrialFinder.trialId().in(trialSet)); trialList2.setBypassCache(true); int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); trialList2.forceResolve(); assertEquals(count+1, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); this.genericRetrievalTest(directSql, trialList2, false); TrialList trialList3 = new TrialList(TrialFinder.trialId().in(trialSet)); count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); trialList3.forceResolve(); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); }
Example #24
Source File: TestSybaseGeneralTestCases.java From reladomo with Apache License 2.0 | 6 votes |
public void testUpdateOneRowManyTimes() throws SQLException { final Order orderOne = OrderFinder.findOne(OrderFinder.orderId().eq(1)); assertNotNull(orderOne); final Order orderTwo = OrderFinder.findOne(OrderFinder.orderId().eq(2)); assertNotNull(orderTwo); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { @Override public Object executeTransaction(MithraTransaction tx) throws Throwable { for (int i = 0; i < 1000; i++) { orderOne.setUserId(0); orderTwo.setUserId(7); orderOne.setUserId(1); orderTwo.setUserId(6); } return null; } }); assertEquals(orderOne.getUserId(), 1); }
Example #25
Source File: TransactionalSemiUniqueDatedIndex.java From reladomo with Apache License 2.0 | 6 votes |
public Object get(Object dataHolder, Extractor[] extractors) // for multi attribute indicies { Object result = null; TransactionLocalStorage txStorage = (TransactionLocalStorage) perTransactionStorage.get(MithraManagerProvider.getMithraManager().zGetCurrentTransactionWithNoCheck()); FullSemiUniqueDatedIndex perThreadAdded = this.getPerThreadAddedIndex(txStorage); if (perThreadAdded != null) { result = perThreadAdded.get(dataHolder, extractors); } if (result == null) { result = this.mainIndex.get(dataHolder, extractors); result = this.checkDeletedIndex(result, txStorage); } return result; }
Example #26
Source File: AbstractTransactionalOperationBasedList.java From reladomo with Apache License 2.0 | 6 votes |
public void deleteAll(DelegatingList<E> delegatingList) { Operation op = delegatingList.getOperation(); verifyNonDatedList(op); boolean oneByOne = (op instanceof MappedOperation); if (!oneByOne) { UnifiedSet portals = new UnifiedSet(3); op.addDependentPortalsToSet(portals); MithraObjectPortal portal = op.getResultObjectPortal(); oneByOne = portals.size() > 1 || portal.getSuperClassPortals() != null || portal.getJoinedSubClassPortals() != null; } TransactionalCommand command = null; if (oneByOne) { command = new DeleteAllOneByOneCommand(delegatingList); } else { command = new DeleteAllTransactionalCommand(delegatingList, this); } MithraManagerProvider.getMithraManager().executeTransactionalCommand(command); }
Example #27
Source File: TestOptimisticTransactionParticipation.java From reladomo with Apache License 2.0 | 6 votes |
public void testBatchUpdateTwoAttributesWithTimestamp() { final long now = System.currentTimeMillis() - 10; final OptimisticOrderWithTimestamp orderA = OptimisticOrderWithTimestampFinder.findOne(OptimisticOrderWithTimestampFinder.orderId().eq(1)); final OptimisticOrderWithTimestamp orderB = OptimisticOrderWithTimestampFinder.findOne(OptimisticOrderWithTimestampFinder.orderId().eq(2)); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand() { public Object executeTransaction(MithraTransaction tx) throws Throwable { assertEquals(originalUpdateTime, orderA.getUpdateTime()); orderA.setState("new state"); orderA.setTrackingId("new tid14"); assertTrue(orderA.getUpdateTime().getTime() > now); orderB.setState("new state 2"); orderB.setTrackingId("new tid15"); return null; } }); OptimisticOrderWithTimestamp order2 = OptimisticOrderWithTimestampFinder.findOneBypassCache(OptimisticOrderWithTimestampFinder.orderId().eq(1)); assertTrue(order2.getUpdateTime().getTime() > now); assertEquals("new state", order2.getState()); assertEquals("new tid14", order2.getTrackingId()); order2 = OptimisticOrderWithTimestampFinder.findOneBypassCache(OptimisticOrderWithTimestampFinder.orderId().eq(2)); assertEquals("new state 2", order2.getState()); assertEquals("new tid15", order2.getTrackingId()); }
Example #28
Source File: MithraAbstractObjectPortal.java From reladomo with Apache License 2.0 | 6 votes |
public void registerForApplicationClassLevelNotification(Set sourceAttributeValueSet, MithraApplicationClassLevelNotificationListener listener) { if (sourceAttributeValueSet == null || sourceAttributeValueSet.isEmpty()) { throw new MithraBusinessException("Source attribute value set is mandatory"); } if (this.getFinder().getSourceAttribute() == null && (sourceAttributeValueSet.size() != 1 || !sourceAttributeValueSet.contains(null))) { throw new MithraBusinessException("The source attribute value set must contain a single null value because this class does not have a source attribute"); } if (this.isForTempObject()) return; Collection<String> databaseIdentifiers = this.extractDatabaseIdentifiers(sourceAttributeValueSet).values(); for (String databaseIdentifier : databaseIdentifiers) { MithraManagerProvider.getMithraManager().getNotificationEventManager(). registerForApplicationClassLevelNotification(databaseIdentifier, listener, this.getFinder()); } }
Example #29
Source File: MithraPerformanceDataTest.java From reladomo with Apache License 2.0 | 6 votes |
public void testNoTransactionPerformanceDataIsRecordedIfFlagIsNotSet() { MithraManagerProvider.getMithraManager().setCaptureTransactionLevelPerformanceData(false); int retrieveCountBeforeAnything = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); MithraManagerProvider.getMithraManager().executeTransactionalCommand(new TransactionalCommand<Object>() { @Override public Object executeTransaction(MithraTransaction tx) throws Throwable { OrderList result = OrderFinder.findMany(OrderFinder.all()); result.forceResolve(); Assert.assertNull(tx.getTransactionPerformanceData()); Assert.assertEquals(0, tx.getDatabaseRetrieveCount()); return null; } }); Assert.assertEquals(1, OrderFinder.getMithraObjectPortal().getPerformanceData().getDataForFind().getTotalOperations()); Assert.assertEquals(1, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount() - retrieveCountBeforeAnything); }
Example #30
Source File: TestByteArray.java From reladomo with Apache License 2.0 | 6 votes |
public void testPrimaryKey() { WallCrossImplList list = new WallCrossImplList(WallCrossImplFinder.all()); assertEquals(3, list.size()); int count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); byte[] data = new byte[3]; data[0] = toByte(0xFF); data[1] = toByte(0xFF); data[2] = toByte(0xFF); WallCrossImpl first = WallCrossImplFinder.findOne(WallCrossImplFinder.listId().eq(data)); assertNotNull(first); assertEquals(1, first.getEntityid()); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); ListEntryContactsImpl contacts = ListEntryContactsImplFinder.findOne(ListEntryContactsImplFinder.listId().eq(data).and( ListEntryContactsImplFinder.emplId().eq("one"))); assertNotNull(contacts); assertEquals("x", contacts.getListEntryRole()); count = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount(); assertSame(contacts, ListEntryContactsImplFinder.findOne(ListEntryContactsImplFinder.listId().eq(data).and( ListEntryContactsImplFinder.emplId().eq("one")))); assertEquals(count, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount()); }