Package javax.jdo.datastore

Examples of javax.jdo.datastore.Sequence


  public void testSequenceId2() {
    logger.log(BasicLevel.DEBUG, "***************testSequenceId2*****************");
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.getObjectIdClass(Phone.class);
    //get the sequence
    Sequence s = pm.getSequence(PHONE_SEQ);
    assertNotNull("Sequence " + PHONE_SEQ + " should not be null.", s);
    Phone p1 = new Phone();
    p1.setName("phone 1");
    Phone p2 = new Phone();
    p2.setName("phone 2");
View Full Code Here


    logger.log(BasicLevel.DEBUG, "***************testAllocateRdbSequence*****************");
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      pm.getObjectIdClass(Phone.class);
      //get the sequence
      Sequence s = pm.getSequence(PHONE_SEQ);
      assertNotNull("Sequence " + PHONE_SEQ + " should not be null.", s);
      Phone[] phones = new Phone[ADDITIONAL];
      long timeAllocate = System.currentTimeMillis();
      pm.currentTransaction().begin();
      //allocate
      s.allocate(ADDITIONAL);
      for (int i = 0; i < ADDITIONAL ; i++) {
        phones[i] = new Phone();
        phones[i].setName("phone " + i);
      }
      //make persistent
View Full Code Here

  public void testApplicationId1() {
    logger.log(BasicLevel.DEBUG, "***************testApplicationId1*****************");
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.getObjectIdClass(Suitcase.class);
    //get the sequence
    Sequence s = pm.getSequence(SUITCASE_SEQ);
    assertNotNull("Sequence " + SUITCASE_SEQ + " should not be null.", s);
    Suitcase s1 = new Suitcase();
    s1.setColor("black");
    Suitcase s2 = new Suitcase();
    s2.setColor("grey");
    logger.log(BasicLevel.DEBUG, "Value is " + s.currentValue());
    //make persistent
    pm.currentTransaction().begin();
    pm.makePersistent(s1);
    pm.makePersistent(s2);
    pm.currentTransaction().commit();
    assertTrue(s1.getId() < s2.getId());
    logger.log(BasicLevel.DEBUG, "After commit, value is " + s.currentValue());
        pm.close();
  }
View Full Code Here

  public void testApplicationId2() {
    logger.log(BasicLevel.DEBUG, "***************testApplicationId2*****************");
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.getObjectIdClass(CompactDisc.class);
    //get the sequence
    Sequence s = pm.getSequence(CD_SEQ);
    assertNotNull("Sequence " + CD_SEQ + " should not be null.", s);
    CompactDisc cd1 = new CompactDisc();
    cd1.setTitle("cd1");
    CompactDisc cd2 = new CompactDisc();
    cd1.setTitle("cd2");
View Full Code Here

    logger.log(BasicLevel.DEBUG, "***************testSequenceInheritance1*****************");
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      pm.getObjectIdClass(Article.class);
      //  get the sequence
      Sequence s = pm.getSequence(ARTICLE_SEQ);
      assertNotNull("Sequence " + ARTICLE_SEQ + " should not be null.", s);
      s.allocate(ADDITIONAL);
      Article articles[] = new Article[ADDITIONAL];
      for (int i = 0; i < ADDITIONAL; i++) {
        if (i%2 == 0) {
          articles[i] = new Service();
        } else {
View Full Code Here

        flush();
        // TODO: verify consistency of state in the WS
    }
   
    public Sequence getSequence(String name) {
        Sequence s = (Sequence) pmf.getSequenceManager().getSequence(name);
        if (s == null) {
          throw new JDOUserException("The sequence " + name + " has not been found."
              + "Be sure that one class of the package the sequence belongs to has been loaded.");
        }
        return s;
View Full Code Here

    // are any other allocations happening we can't assert on exact values.
    // uncomment this check and the others below when we bring the local
    // allocator in line with the prod allocator
    // assertEquals(range.getEnd().getId(), pojo.getId() - 1);
    assertTrue(range.getEnd().getId() < pojo.getId());
    Sequence seq = pm.getSequence("jdo1b");
//    assertEquals(pojo.getId() + 12, seq.nextValue());
    assertTrue(pojo.getId() + 12 <= seq.nextValue());
//    assertEquals(pojo.getId() + 13, seq.nextValue());
    assertTrue(pojo.getId() + 13 <= seq.nextValue());
    assertEquals(Utils.newArrayList("jdothat2", "jdothat2"), sequenceNames);
    assertEquals(Utils.newArrayList(12L, 12L), sequenceBatchSizes);
    sequenceNames.clear();
    sequenceBatchSizes.clear();
    // getting a sequence always gets you a fresh batch
    seq = pm.getSequence("jdo1b");
//    assertEquals(pojo.getId() + 24, seq.nextValue());
    assertTrue(pojo.getId() + 24 <= seq.nextValue());
//    assertEquals(pojo.getId() + 25, seq.nextValue());
    assertTrue(pojo.getId() + 25 <= seq.nextValue());
    assertEquals(Utils.newArrayList("jdothat2"), sequenceNames);
    assertEquals(Utils.newArrayList(12L), sequenceBatchSizes);
  }
View Full Code Here

        if (seqmd == null)
        {
            throw new JDOUserException(LOCALISER.msg("017000", sequenceName));
        }

        Sequence seq = null;
        if (seqmd.getFactoryClass() != null)
        {
            // User has specified a factory class
            seq = pmf.getSequenceForFactoryClass(seqmd.getFactoryClass());
            if (seq == null)
View Full Code Here

TOP

Related Classes of javax.jdo.datastore.Sequence

Copyright © 2018 www.massapicom. 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.