Package org.apache.cayenne

Examples of org.apache.cayenne.ObjectContext.deleteObject()


          Mail m = rsMail.get(id-1);
          String response = "Deleted " + constructMessage(id, rsMail.size(), m);

          try {
            ObjectContext context = commanderAccount.getObjectContext();
            context.deleteObject(m);
            commanderAccount.updateRow();
            user.sendChat(response, true);

            context.performQuery(new RefreshQuery(commanderAccount));
          } catch(Exception e) {
View Full Code Here


          throw new CommandFailedWithDetailsException("You have unread mail!");

        try {
          ObjectContext context = commanderAccount.getObjectContext();
          for(Mail m : commanderAccount.getRecievedMail())
            context.deleteObject(m);
          commanderAccount.updateRow();
          user.sendChat("Mailbox cleaned!", whisperBack);
        } catch(Exception e) {
          throw new CommandFailedWithDetailsException("Failed to delete mail", e);
        }
View Full Code Here

        a.addToPaintingArray(p2);

        a.removeFromPaintingArray(p2);

        // this causes an error on commit
        child.deleteObject(p2);

        child.commitChangesToParent();

    }
   
View Full Code Here

        p.setPaintingTitle("X");
        a.addToPaintingArray(p);

        childContext.commitChangesToParent();

        childContext.deleteObject(p);
        a.removeFromPaintingArray(p);

        childContext.commitChangesToParent();
    }
View Full Code Here

        assertEquals(4, objects.size());

        // delete AND modify
        Artist childDeleted = (Artist) objects.get(2);
        childContext.deleteObject(childDeleted);
        childDeleted.setArtistName("DDD");

        // don't block queries - on delete Cayenne may need to resolve delete rules via
        // fetch
        childContext.commitChangesToParent();
View Full Code Here

        Artist childCommitted = (Artist) objects.get(1);

        // delete AND modify
        Artist childDeleted = (Artist) objects.get(2);
        childContext.deleteObject(childDeleted);
        childDeleted.setArtistName("DDD");

        Artist childHollow = (Artist) objects.get(3);
        childContext.invalidateObjects(Collections.singleton(childHollow));
View Full Code Here

                LifecycleEvent.POST_REMOVE,
                Artist.class,
                listener2,
                "publicCallback");

        context.deleteObject(a1);
        context.commitChanges();

        assertTrue(a1.isPostRemoved());
        assertSame(a1, listener2.getPublicCalledbackEntity());
    }
View Full Code Here

                listener2,
                "publicCallback");

        // change before removing
        a1.setArtistName("YY");
        context.deleteObject(a1);
        context.commitChanges();

        assertNull(listener2.getPublicCalledbackEntity());
        assertSame(a1, listener1.getPublicCalledbackEntity());
    }
View Full Code Here

                listener2,
                "publicCallback");

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.deleteObject(a1);
        context.commitChanges();

        assertNull(listener0.getPublicCalledbackEntity());
        assertNull(listener1.getPublicCalledbackEntity());
        assertNull(listener2.getPublicCalledbackEntity());
View Full Code Here

        country.setContinent(continent);
        assertEquals(continent.getCountries().size(), 1);
       
        context.commitChanges();
       
        context.deleteObject(country);
        assertEquals(continent.getCountries().size(), 0);
        continent.setName("Australia");
       
        context.commitChanges();
        context.performQuery(new RefreshQuery());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.