2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
7 package com.sleepycat.persist.test;
9 import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
10 import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
12 import java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.HashMap;
17 import java.util.StringTokenizer;
19 import junit.framework.TestCase;
21 import com.sleepycat.db.DatabaseException;
22 import com.sleepycat.db.Environment;
23 import com.sleepycat.persist.EntityStore;
24 import com.sleepycat.persist.PrimaryIndex;
25 import com.sleepycat.persist.SecondaryIndex;
26 import com.sleepycat.persist.StoreConfig;
27 import com.sleepycat.persist.evolve.Conversion;
28 import com.sleepycat.persist.evolve.Converter;
29 import com.sleepycat.persist.evolve.Deleter;
30 import com.sleepycat.persist.evolve.EntityConverter;
31 import com.sleepycat.persist.evolve.Mutations;
32 import com.sleepycat.persist.evolve.Renamer;
33 import com.sleepycat.persist.model.Entity;
34 import com.sleepycat.persist.model.EntityModel;
35 import com.sleepycat.persist.model.KeyField;
36 import com.sleepycat.persist.model.Persistent;
37 import com.sleepycat.persist.model.PersistentProxy;
38 import com.sleepycat.persist.model.PrimaryKey;
39 import com.sleepycat.persist.model.SecondaryKey;
40 import com.sleepycat.persist.raw.RawObject;
41 import com.sleepycat.persist.raw.RawStore;
42 import com.sleepycat.persist.raw.RawType;
45 * Nested classes are modified versions of classes of the same name in
46 * EvolveClasses.java.original. See EvolveTestBase.java for the steps that are
47 * taken to add a new class (test case).
53 private static final String PREFIX = EvolveClasses.class.getName() + '$';
54 private static final String CASECLS = EvolveCase.class.getName();
56 private static RawObject readRaw(RawStore store,
58 Object... classVersionPairs)
59 throws DatabaseException {
61 return readRaw(store, null, key, classVersionPairs);
65 * Reads a raw object and checks its superclass names and versions.
67 private static RawObject readRaw(RawStore store,
70 Object... classVersionPairs)
71 throws DatabaseException {
73 TestCase.assertNotNull(store);
74 TestCase.assertNotNull(key);
76 if (entityClsName == null) {
77 entityClsName = (String) classVersionPairs[0];
79 PrimaryIndex<Object, RawObject> index =
80 store.getPrimaryIndex(entityClsName);
81 TestCase.assertNotNull(index);
83 RawObject obj = index.get(key);
84 TestCase.assertNotNull(obj);
86 checkRawType(obj.getType(), classVersionPairs);
88 RawObject superObj = obj.getSuper();
89 for (int i = 2; i < classVersionPairs.length; i += 2) {
90 Object[] a = new Object[classVersionPairs.length - i];
91 System.arraycopy(classVersionPairs, i, a, 0, a.length);
92 TestCase.assertNotNull(superObj);
93 checkRawType(superObj.getType(), a);
94 superObj = superObj.getSuper();
101 * Reads a raw object and checks its superclass names and versions.
103 private static void checkRawType(RawType type,
104 Object... classVersionPairs) {
105 TestCase.assertNotNull(type);
106 TestCase.assertNotNull(classVersionPairs);
107 TestCase.assertTrue(classVersionPairs.length % 2 == 0);
109 for (int i = 0; i < classVersionPairs.length; i += 2) {
110 String clsName = (String) classVersionPairs[i];
111 int clsVersion = (Integer) classVersionPairs[i + 1];
112 TestCase.assertEquals(clsName, type.getClassName());
113 TestCase.assertEquals(clsVersion, type.getVersion());
114 type = type.getSuperType();
116 TestCase.assertNull(type);
120 * Checks that a raw object contains the specified field values. Does not
121 * check superclass fields.
123 private static void checkRawFields(RawObject obj,
124 Object... nameValuePairs) {
125 TestCase.assertNotNull(obj);
126 TestCase.assertNotNull(obj.getValues());
127 TestCase.assertNotNull(nameValuePairs);
128 TestCase.assertTrue(nameValuePairs.length % 2 == 0);
130 Map<String, Object> values = obj.getValues();
131 TestCase.assertEquals(nameValuePairs.length / 2, values.size());
133 for (int i = 0; i < nameValuePairs.length; i += 2) {
134 String name = (String) nameValuePairs[i];
135 Object value = nameValuePairs[i + 1];
136 TestCase.assertEquals(name, value, values.get(name));
140 private static Map<String, Object> makeValues(Object... nameValuePairs) {
141 TestCase.assertTrue(nameValuePairs.length % 2 == 0);
142 Map<String, Object> values = new HashMap<String, Object>();
143 for (int i = 0; i < nameValuePairs.length; i += 2) {
144 values.put((String) nameValuePairs[i], nameValuePairs[i + 1]);
150 * Disallow removing an entity class when no Deleter mutation is specified.
152 static class DeletedEntity1_ClassRemoved_NoMutation extends EvolveCase {
154 private static final String NAME =
155 PREFIX + "DeletedEntity1_ClassRemoved";
158 public String getStoreOpenException() {
159 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity1_ClassRemoved version: 0 Error: java.lang.ClassNotFoundException: com.sleepycat.persist.test.EvolveClasses$DeletedEntity1_ClassRemoved";
163 void checkUnevolvedModel(EntityModel model, Environment env) {
164 checkEntity(true, model, env, NAME, 0, "skey");
165 checkVersions(model, NAME, 0);
169 void readRawObjects(RawStore store,
170 boolean expectEvolved,
171 boolean expectUpdated)
172 throws DatabaseException {
177 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
178 checkRawFields(obj, "key", 99, "skey", 88);
183 * Allow removing an entity class when a Deleter mutation is specified.
185 static class DeletedEntity2_ClassRemoved_WithDeleter extends EvolveCase {
187 private static final String NAME =
188 PREFIX + "DeletedEntity2_ClassRemoved";
191 int getNRecordsExpected() {
196 Mutations getMutations() {
197 Mutations m = new Mutations();
198 m.addDeleter(new Deleter(NAME, 0));
203 void checkEvolvedModel(EntityModel model,
205 boolean oldTypesExist) {
206 checkEntity(false, model, env, NAME, 0, "skey");
208 checkVersions(model, NAME, 0);
213 void readRawObjects(RawStore store,
214 boolean expectEvolved,
215 boolean expectUpdated)
216 throws DatabaseException {
221 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
222 checkRawFields(obj, "key", 99, "skey", 88);
227 * Disallow removing the Entity annotation when no Deleter mutation is
230 static class DeletedEntity3_AnnotRemoved_NoMutation extends EvolveCase {
232 private static final String NAME =
233 DeletedEntity3_AnnotRemoved_NoMutation.class.getName();
236 public String getStoreOpenException() {
237 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity3_AnnotRemoved_NoMutation version: 0 Error: java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: com.sleepycat.persist.test.EvolveClasses$DeletedEntity3_AnnotRemoved_NoMutation";
241 void checkUnevolvedModel(EntityModel model, Environment env) {
242 checkEntity(true, model, env, NAME, 0, "skey");
243 checkVersions(model, NAME, 0);
247 void readRawObjects(RawStore store,
248 boolean expectEvolved,
249 boolean expectUpdated)
250 throws DatabaseException {
255 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
256 checkRawFields(obj, "key", 99, "skey", 88);
261 * Allow removing the Entity annotation when a Deleter mutation is
264 static class DeletedEntity4_AnnotRemoved_WithDeleter extends EvolveCase {
266 private static final String NAME =
267 DeletedEntity4_AnnotRemoved_WithDeleter.class.getName();
270 int getNRecordsExpected() {
275 Mutations getMutations() {
276 Mutations m = new Mutations();
277 m.addDeleter(new Deleter(NAME, 0));
282 void checkEvolvedModel(EntityModel model,
284 boolean oldTypesExist) {
285 checkEntity(false, model, env, NAME, 0, "skey");
287 checkVersions(model, NAME, 0);
292 void readObjects(EntityStore store, boolean doUpdate) {
294 store.getPrimaryIndex
296 DeletedEntity4_AnnotRemoved_WithDeleter.class);
298 } catch (Exception e) {
300 ("java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity4_AnnotRemoved_WithDeleter",
306 void readRawObjects(RawStore store,
307 boolean expectEvolved,
308 boolean expectUpdated)
309 throws DatabaseException {
314 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
315 checkRawFields(obj, "key", 99, "skey", 88);
320 * Disallow changing the Entity annotation to Persistent when no Deleter
321 * mutation is specified.
323 @Persistent(version=1)
324 static class DeletedEntity5_EntityToPersist_NoMutation extends EvolveCase {
326 private static final String NAME =
327 DeletedEntity5_EntityToPersist_NoMutation.class.getName();
330 public String getStoreOpenException() {
331 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity5_EntityToPersist_NoMutation version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity5_EntityToPersist_NoMutation version: 1 Error: @Entity switched to/from @Persistent";
335 void checkUnevolvedModel(EntityModel model, Environment env) {
336 checkEntity(true, model, env, NAME, 0, "skey");
337 checkVersions(model, NAME, 0);
341 void readRawObjects(RawStore store,
342 boolean expectEvolved,
343 boolean expectUpdated)
344 throws DatabaseException {
349 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
350 checkRawFields(obj, "key", 99, "skey", 88);
355 * Allow changing the Entity annotation to Persistent when a Deleter
356 * mutation is specified.
358 @Persistent(version=1)
359 static class DeletedEntity6_EntityToPersist_WithDeleter extends EvolveCase {
361 private static final String NAME =
362 DeletedEntity6_EntityToPersist_WithDeleter.class.getName();
363 private static final String NAME2 =
364 Embed_DeletedEntity6_EntityToPersist_WithDeleter.class.getName();
367 int getNRecordsExpected() {
372 Mutations getMutations() {
373 Mutations m = new Mutations();
374 m.addDeleter(new Deleter(NAME, 0));
379 void checkEvolvedModel(EntityModel model,
381 boolean oldTypesExist) {
382 checkNonEntity(true, model, env, NAME, 1);
384 checkVersions(model, NAME, 1, NAME, 0);
386 checkVersions(model, NAME, 1);
391 void readObjects(EntityStore store, boolean doUpdate)
392 throws DatabaseException {
394 /* Cannot get the primary index for the former entity class. */
396 store.getPrimaryIndex
398 DeletedEntity6_EntityToPersist_WithDeleter.class);
400 } catch (Exception e) {
402 ("java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity6_EntityToPersist_WithDeleter",
406 if (newMetadataWritten) {
407 /* Can embed the new persistent class in another entity. */
409 Embed_DeletedEntity6_EntityToPersist_WithDeleter>
410 index = store.getPrimaryIndex
412 Embed_DeletedEntity6_EntityToPersist_WithDeleter.class);
415 Embed_DeletedEntity6_EntityToPersist_WithDeleter embed =
416 new Embed_DeletedEntity6_EntityToPersist_WithDeleter();
418 embed = index.get(embed.key);
419 /* This new type should exist only after update. */
420 Environment env = store.getEnvironment();
421 EntityModel model = store.getModel();
422 checkEntity(true, model, env, NAME2, 0, null);
423 checkVersions(model, NAME2, 0);
429 void readRawObjects(RawStore store,
430 boolean expectEvolved,
431 boolean expectUpdated)
432 throws DatabaseException {
437 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
438 checkRawFields(obj, "key", 99, "skey", 88);
443 static class Embed_DeletedEntity6_EntityToPersist_WithDeleter {
448 DeletedEntity6_EntityToPersist_WithDeleter embedded =
449 new DeletedEntity6_EntityToPersist_WithDeleter();
453 * Disallow removing a Persistent class when no Deleter mutation is
454 * specified, even when the Entity class that embedded the Persistent class
455 * is deleted properly (by removing the Entity annotation in this case).
457 static class DeletedPersist1_ClassRemoved_NoMutation extends EvolveCase {
459 private static final String NAME =
460 PREFIX + "DeletedPersist1_ClassRemoved";
462 private static final String NAME2 =
463 DeletedPersist1_ClassRemoved_NoMutation.class.getName();
466 Mutations getMutations() {
467 Mutations m = new Mutations();
468 m.addDeleter(new Deleter(NAME2, 0));
473 public String getStoreOpenException() {
474 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist1_ClassRemoved version: 0 Error: java.lang.ClassNotFoundException: com.sleepycat.persist.test.EvolveClasses$DeletedPersist1_ClassRemoved";
478 void checkUnevolvedModel(EntityModel model, Environment env) {
479 checkNonEntity(true, model, env, NAME, 0);
480 checkEntity(true, model, env, NAME2, 0, null);
481 checkVersions(model, NAME, 0);
482 checkVersions(model, NAME2, 0);
486 void readRawObjects(RawStore store,
487 boolean expectEvolved,
488 boolean expectUpdated)
489 throws DatabaseException {
495 RawType embedType = store.getModel().getRawType(NAME);
496 checkRawType(embedType, NAME, 0);
499 new RawObject(embedType, makeValues("f", 123), null);
501 RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
502 checkRawFields(obj, "key", 99, "embed", embed);
507 * Allow removing a Persistent class when a Deleter mutation is
508 * specified, and the Entity class that embedded the Persistent class
509 * is also deleted properly (by removing the Entity annotation in this
512 static class DeletedPersist2_ClassRemoved_WithDeleter extends EvolveCase {
514 private static final String NAME =
515 PREFIX + "DeletedPersist2_ClassRemoved";
516 private static final String NAME2 =
517 DeletedPersist2_ClassRemoved_WithDeleter.class.getName();
520 int getNRecordsExpected() {
525 Mutations getMutations() {
526 Mutations m = new Mutations();
527 m.addDeleter(new Deleter(NAME, 0));
528 m.addDeleter(new Deleter(NAME2, 0));
533 void checkEvolvedModel(EntityModel model,
535 boolean oldTypesExist) {
536 checkNonEntity(false, model, env, NAME, 0);
537 checkEntity(false, model, env, NAME2, 0, null);
539 checkVersions(model, NAME, 0);
540 checkVersions(model, NAME2, 0);
545 void readObjects(EntityStore store, boolean doUpdate) {
547 store.getPrimaryIndex
549 DeletedPersist2_ClassRemoved_WithDeleter.class);
551 } catch (Exception e) {
553 ("java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist2_ClassRemoved_WithDeleter",
559 void readRawObjects(RawStore store,
560 boolean expectEvolved,
561 boolean expectUpdated)
562 throws DatabaseException {
568 RawType embedType = store.getModel().getRawType(NAME);
569 checkRawType(embedType, NAME, 0);
572 new RawObject(embedType, makeValues("f", 123), null);
574 RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
575 checkRawFields(obj, "key", 99, "embed", embed);
579 static class DeletedPersist3_AnnotRemoved {
585 * Disallow removing the Persistent annotation when no Deleter mutation is
586 * specified, even when the Entity class that embedded the Persistent class
587 * is deleted properly (by removing the Entity annotation in this case).
589 static class DeletedPersist3_AnnotRemoved_NoMutation extends EvolveCase {
591 private static final String NAME =
592 DeletedPersist3_AnnotRemoved.class.getName();
593 private static final String NAME2 =
594 DeletedPersist3_AnnotRemoved_NoMutation.class.getName();
597 Mutations getMutations() {
598 Mutations m = new Mutations();
599 m.addDeleter(new Deleter(NAME2, 0));
604 public String getStoreOpenException() {
605 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist3_AnnotRemoved version: 0 Error: java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: com.sleepycat.persist.test.EvolveClasses$DeletedPersist3_AnnotRemoved";
609 void checkUnevolvedModel(EntityModel model, Environment env) {
610 checkNonEntity(true, model, env, NAME, 0);
611 checkEntity(true, model, env, NAME2, 0, null);
612 checkVersions(model, NAME, 0);
613 checkVersions(model, NAME2, 0);
617 void readRawObjects(RawStore store,
618 boolean expectEvolved,
619 boolean expectUpdated)
620 throws DatabaseException {
626 RawType embedType = store.getModel().getRawType(NAME);
627 checkRawType(embedType, NAME, 0);
630 new RawObject(embedType, makeValues("f", 123), null);
632 RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
633 checkRawFields(obj, "key", 99, "embed", embed);
637 static class DeletedPersist4_AnnotRemoved {
643 * Allow removing the Persistent annotation when a Deleter mutation is
644 * specified, and the Entity class that embedded the Persistent class
645 * is also deleted properly (by removing the Entity annotation in this
648 static class DeletedPersist4_AnnotRemoved_WithDeleter extends EvolveCase {
650 private static final String NAME =
651 DeletedPersist4_AnnotRemoved.class.getName();
652 private static final String NAME2 =
653 DeletedPersist4_AnnotRemoved_WithDeleter.class.getName();
656 int getNRecordsExpected() {
661 Mutations getMutations() {
662 Mutations m = new Mutations();
663 m.addDeleter(new Deleter(NAME, 0));
664 m.addDeleter(new Deleter(NAME2, 0));
669 void checkEvolvedModel(EntityModel model,
671 boolean oldTypesExist) {
672 checkNonEntity(false, model, env, NAME, 0);
673 checkEntity(false, model, env, NAME2, 0, null);
675 checkVersions(model, NAME, 0);
676 checkVersions(model, NAME2, 0);
681 void readObjects(EntityStore store, boolean doUpdate) {
683 store.getPrimaryIndex
685 DeletedPersist4_AnnotRemoved_WithDeleter.class);
687 } catch (Exception e) {
689 ("java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist4_AnnotRemoved_WithDeleter",
695 void readRawObjects(RawStore store,
696 boolean expectEvolved,
697 boolean expectUpdated)
698 throws DatabaseException {
704 RawType embedType = store.getModel().getRawType(NAME);
705 checkRawType(embedType, NAME, 0);
708 new RawObject(embedType, makeValues("f", 123), null);
710 RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
711 checkRawFields(obj, "key", 99, "embed", embed);
716 static class DeletedPersist5_PersistToEntity {
725 * Disallow changing the Entity annotation to Persistent when no Deleter
726 * mutation is specified, even when the Entity class that embedded the
727 * Persistent class is deleted properly (by removing the Entity annotation
730 static class DeletedPersist5_PersistToEntity_NoMutation
733 private static final String NAME =
734 DeletedPersist5_PersistToEntity.class.getName();
735 private static final String NAME2 =
736 DeletedPersist5_PersistToEntity_NoMutation.class.getName();
739 Mutations getMutations() {
740 Mutations m = new Mutations();
741 m.addDeleter(new Deleter(NAME2, 0));
746 public String getStoreOpenException() {
747 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist5_PersistToEntity version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist5_PersistToEntity version: 1 Error: @Entity switched to/from @Persistent";
751 void checkUnevolvedModel(EntityModel model, Environment env) {
752 checkNonEntity(true, model, env, NAME, 0);
753 checkEntity(true, model, env, NAME2, 0, null);
754 checkVersions(model, NAME, 0);
755 checkVersions(model, NAME2, 0);
759 void readRawObjects(RawStore store,
760 boolean expectEvolved,
761 boolean expectUpdated)
762 throws DatabaseException {
768 RawType embedType = store.getModel().getRawType(NAME);
769 checkRawType(embedType, NAME, 0);
772 new RawObject(embedType, makeValues("f", 123), null);
774 RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
775 checkRawFields(obj, "key", 99, "embed", embed);
780 static class DeletedPersist6_PersistToEntity {
789 * Allow changing the Entity annotation to Persistent when a Deleter
790 * mutation is specified, and the Entity class that embedded the Persistent
791 * class is also deleted properly (by removing the Entity annotation in
794 static class DeletedPersist6_PersistToEntity_WithDeleter
797 private static final String NAME =
798 DeletedPersist6_PersistToEntity.class.getName();
799 private static final String NAME2 =
800 DeletedPersist6_PersistToEntity_WithDeleter.class.getName();
803 int getNRecordsExpected() {
808 Mutations getMutations() {
809 Mutations m = new Mutations();
810 m.addDeleter(new Deleter(NAME, 0));
811 m.addDeleter(new Deleter(NAME2, 0));
816 void checkEvolvedModel(EntityModel model,
818 boolean oldTypesExist) {
819 checkEntity(false, model, env, NAME2, 0, null);
821 checkVersions(model, NAME, 1, NAME, 0);
822 checkVersions(model, NAME2, 0);
824 checkVersions(model, NAME, 1);
829 void readObjects(EntityStore store, boolean doUpdate)
830 throws DatabaseException {
832 /* Cannot get the primary index for the former entity class. */
834 store.getPrimaryIndex
836 DeletedPersist6_PersistToEntity_WithDeleter.class);
838 } catch (Exception e) {
840 ("java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist6_PersistToEntity_WithDeleter",
844 if (newMetadataWritten) {
845 /* Can use the primary index of the new entity class. */
846 PrimaryIndex<Integer,
847 DeletedPersist6_PersistToEntity>
848 index = store.getPrimaryIndex
850 DeletedPersist6_PersistToEntity.class);
853 DeletedPersist6_PersistToEntity obj =
854 new DeletedPersist6_PersistToEntity();
856 obj = index.get(obj.key);
857 /* This new type should exist only after update. */
858 Environment env = store.getEnvironment();
859 EntityModel model = store.getModel();
860 checkEntity(true, model, env, NAME, 1, null);
866 void copyRawObjects(RawStore rawStore, EntityStore newStore)
867 throws DatabaseException {
869 PrimaryIndex<Integer,
870 DeletedPersist6_PersistToEntity>
871 index = newStore.getPrimaryIndex
873 DeletedPersist6_PersistToEntity.class);
874 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
875 index.put((DeletedPersist6_PersistToEntity)
876 newStore.getModel().convertRawObject(raw));
880 void readRawObjects(RawStore store,
881 boolean expectEvolved,
882 boolean expectUpdated)
883 throws DatabaseException {
889 RawType embedType = store.getModel().getRawType(NAME);
890 checkRawType(embedType, NAME, 0);
893 new RawObject(embedType, makeValues("f", 123), null);
895 RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
896 checkRawFields(obj, "key", 99, "embed", embed);
901 * Disallow renaming an entity class without a Renamer mutation.
904 static class RenamedEntity1_NewEntityName_NoMutation
907 private static final String NAME =
908 PREFIX + "RenamedEntity1_NewEntityName";
909 private static final String NAME2 =
910 RenamedEntity1_NewEntityName_NoMutation.class.getName();
915 @SecondaryKey(relate=ONE_TO_ONE)
919 public String getStoreOpenException() {
920 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$RenamedEntity1_NewEntityName version: 0 Error: java.lang.ClassNotFoundException: com.sleepycat.persist.test.EvolveClasses$RenamedEntity1_NewEntityName";
924 void checkUnevolvedModel(EntityModel model, Environment env) {
925 checkEntity(true, model, env, NAME, 0, "skey");
926 checkVersions(model, NAME, 0);
930 void readRawObjects(RawStore store,
931 boolean expectEvolved,
932 boolean expectUpdated)
933 throws DatabaseException {
938 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
939 checkRawFields(obj, "key", 99, "skey", 88);
944 * Allow renaming an entity class with a Renamer mutation.
947 static class RenamedEntity2_NewEntityName_WithRenamer
950 private static final String NAME =
951 PREFIX + "RenamedEntity2_NewEntityName";
952 private static final String NAME2 =
953 RenamedEntity2_NewEntityName_WithRenamer.class.getName();
958 @SecondaryKey(relate=ONE_TO_ONE)
962 Mutations getMutations() {
963 Mutations m = new Mutations();
964 m.addRenamer(new Renamer(NAME, 0, NAME2));
969 void checkEvolvedModel(EntityModel model,
971 boolean oldTypesExist) {
972 checkEntity(false, model, env, NAME, 0, null);
973 checkEntity(true, model, env, NAME2, 1, null);
975 checkVersions(model, NAME2, 1, NAME, 0);
977 checkVersions(model, NAME2, 1);
982 void readObjects(EntityStore store, boolean doUpdate)
983 throws DatabaseException {
985 PrimaryIndex<Integer, RenamedEntity2_NewEntityName_WithRenamer>
986 index = store.getPrimaryIndex
988 RenamedEntity2_NewEntityName_WithRenamer.class);
989 RenamedEntity2_NewEntityName_WithRenamer obj = index.get(key);
990 TestCase.assertNotNull(obj);
991 TestCase.assertEquals(99, obj.key);
992 TestCase.assertEquals(88, obj.skey);
994 SecondaryIndex<Integer, Integer,
995 RenamedEntity2_NewEntityName_WithRenamer>
996 sindex = store.getSecondaryIndex(index, Integer.class, "skey");
997 obj = sindex.get(88);
998 TestCase.assertNotNull(obj);
999 TestCase.assertEquals(99, obj.key);
1000 TestCase.assertEquals(88, obj.skey);
1008 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1009 throws DatabaseException {
1011 PrimaryIndex<Integer, RenamedEntity2_NewEntityName_WithRenamer>
1012 index = newStore.getPrimaryIndex
1014 RenamedEntity2_NewEntityName_WithRenamer.class);
1015 RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1016 index.put((RenamedEntity2_NewEntityName_WithRenamer)
1017 newStore.getModel().convertRawObject(raw));
1021 void readRawObjects(RawStore store,
1022 boolean expectEvolved,
1023 boolean expectUpdated)
1024 throws DatabaseException {
1027 if (expectEvolved) {
1028 obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1030 obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1032 checkRawFields(obj, "key", 99, "skey", 88);
1037 static class DeleteSuperclass1_BaseClass
1038 extends EvolveCase {
1044 * Disallow deleting a superclass from the hierarchy when the superclass
1045 * has persistent fields and no Deleter or Converter is specified.
1048 static class DeleteSuperclass1_NoMutation
1049 extends EvolveCase {
1051 private static final String NAME =
1052 DeleteSuperclass1_BaseClass.class.getName();
1053 private static final String NAME2 =
1054 DeleteSuperclass1_NoMutation.class.getName();
1062 public String getStoreOpenException() {
1063 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeleteSuperclass1_NoMutation version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeleteSuperclass1_NoMutation version: 0 Error: When a superclass is removed from the class hierarchy, the superclass or all of its persistent fields must be deleted with a Deleter: com.sleepycat.persist.test.EvolveClasses$DeleteSuperclass1_BaseClass";
1067 void checkUnevolvedModel(EntityModel model, Environment env) {
1068 checkNonEntity(true, model, env, NAME, 0);
1069 checkEntity(true, model, env, NAME2, 0, null);
1070 checkVersions(model, NAME, 0);
1071 checkVersions(model, NAME2, 0);
1075 void readRawObjects(RawStore store,
1076 boolean expectEvolved,
1077 boolean expectUpdated)
1078 throws DatabaseException {
1080 if (expectEvolved) {
1083 RawObject obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1084 checkRawFields(obj, "key", 99, "ff", 88);
1085 checkRawFields(obj.getSuper(), "f", 123);
1086 checkRawFields(obj.getSuper().getSuper());
1091 static class DeleteSuperclass2_BaseClass
1092 extends EvolveCase {
1096 @SecondaryKey(relate=ONE_TO_ONE)
1101 * Allow deleting a superclass from the hierarchy when the superclass has
1102 * persistent fields and a class Converter is specified. Also check that
1103 * the secondary key field in the deleted base class is handled properly.
1106 static class DeleteSuperclass2_WithConverter extends EvolveCase {
1108 private static final String NAME =
1109 DeleteSuperclass2_BaseClass.class.getName();
1110 private static final String NAME2 =
1111 DeleteSuperclass2_WithConverter.class.getName();
1118 @SecondaryKey(relate=ONE_TO_ONE)
1121 @SecondaryKey(relate=ONE_TO_ONE)
1125 Mutations getMutations() {
1126 Mutations m = new Mutations();
1127 m.addConverter(new EntityConverter
1128 (NAME2, 0, new MyConversion(),
1129 Collections.singleton("skey")));
1133 @SuppressWarnings("serial")
1134 static class MyConversion implements Conversion {
1136 transient RawType newType;
1138 public void initialize(EntityModel model) {
1139 newType = model.getRawType(NAME2);
1140 TestCase.assertNotNull(newType);
1143 public Object convert(Object fromValue) {
1144 TestCase.assertNotNull(newType);
1145 RawObject obj = (RawObject) fromValue;
1146 RawObject newSuper = obj.getSuper().getSuper();
1147 return new RawObject(newType, obj.getValues(), newSuper);
1151 public boolean equals(Object other) {
1152 return other instanceof MyConversion;
1157 void checkEvolvedModel(EntityModel model,
1159 boolean oldTypesExist) {
1160 checkEntity(true, model, env, NAME2, 1, null);
1161 if (oldTypesExist) {
1162 checkVersions(model, NAME2, 1, NAME2, 0);
1163 checkNonEntity(true, model, env, NAME, 0);
1164 checkVersions(model, NAME, 0);
1166 checkVersions(model, NAME2, 1);
1171 void readObjects(EntityStore store, boolean doUpdate)
1172 throws DatabaseException {
1174 PrimaryIndex<Integer, DeleteSuperclass2_WithConverter>
1175 index = store.getPrimaryIndex
1177 DeleteSuperclass2_WithConverter.class);
1178 DeleteSuperclass2_WithConverter obj = index.get(99);
1179 TestCase.assertNotNull(obj);
1181 (EvolveCase.class, obj.getClass().getSuperclass());
1182 TestCase.assertEquals(99, obj.key);
1183 TestCase.assertEquals(88, obj.ff);
1184 TestCase.assertEquals(Integer.valueOf(77), obj.skey2);
1185 TestCase.assertEquals(66, obj.skey3);
1192 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1193 throws DatabaseException {
1195 PrimaryIndex<Integer, DeleteSuperclass2_WithConverter>
1196 index = newStore.getPrimaryIndex
1198 DeleteSuperclass2_WithConverter.class);
1199 RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1200 index.put((DeleteSuperclass2_WithConverter)
1201 newStore.getModel().convertRawObject(raw));
1205 void readRawObjects(RawStore store,
1206 boolean expectEvolved,
1207 boolean expectUpdated)
1208 throws DatabaseException {
1211 if (expectEvolved) {
1212 obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1214 obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1217 (obj, "key", 99, "ff", 88, "skey2", 77, "skey3", 66);
1218 if (expectEvolved) {
1219 checkRawFields(obj.getSuper());
1221 checkRawFields(obj.getSuper(), "f", 123, "skey", 456);
1222 checkRawFields(obj.getSuper().getSuper());
1224 Environment env = store.getEnvironment();
1225 assertDbExists(!expectEvolved, env, NAME2, "skey");
1226 assertDbExists(true, env, NAME2, "skey3");
1230 static class DeleteSuperclass3_BaseClass
1231 extends EvolveCase {
1235 @SecondaryKey(relate=ONE_TO_ONE)
1240 * Allow deleting a superclass from the hierarchy when the superclass
1241 * has persistent fields and a class Deleter is specified. Also check that
1242 * the secondary key field in the deleted base class is handled properly.
1245 static class DeleteSuperclass3_WithDeleter extends EvolveCase {
1247 private static final String NAME =
1248 DeleteSuperclass3_BaseClass.class.getName();
1249 private static final String NAME2 =
1250 DeleteSuperclass3_WithDeleter.class.getName();
1258 Mutations getMutations() {
1259 Mutations m = new Mutations();
1260 m.addDeleter(new Deleter(NAME, 0));
1265 void checkEvolvedModel(EntityModel model,
1267 boolean oldTypesExist) {
1268 checkEntity(true, model, env, NAME2, 1, null);
1269 if (oldTypesExist) {
1270 checkVersions(model, NAME2, 1, NAME2, 0);
1271 checkNonEntity(false, model, env, NAME, 0);
1272 checkVersions(model, NAME, 0);
1274 checkVersions(model, NAME2, 1);
1279 void readObjects(EntityStore store, boolean doUpdate)
1280 throws DatabaseException {
1282 PrimaryIndex<Integer, DeleteSuperclass3_WithDeleter>
1283 index = store.getPrimaryIndex
1285 DeleteSuperclass3_WithDeleter.class);
1286 DeleteSuperclass3_WithDeleter obj = index.get(99);
1287 TestCase.assertNotNull(obj);
1289 (EvolveCase.class, obj.getClass().getSuperclass());
1290 TestCase.assertEquals(99, obj.key);
1291 TestCase.assertEquals(88, obj.ff);
1298 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1299 throws DatabaseException {
1301 PrimaryIndex<Integer, DeleteSuperclass3_WithDeleter>
1302 index = newStore.getPrimaryIndex
1304 DeleteSuperclass3_WithDeleter.class);
1305 RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1306 index.put((DeleteSuperclass3_WithDeleter)
1307 newStore.getModel().convertRawObject(raw));
1311 void readRawObjects(RawStore store,
1312 boolean expectEvolved,
1313 boolean expectUpdated)
1314 throws DatabaseException {
1317 if (expectEvolved) {
1318 obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1320 obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1322 checkRawFields(obj, "key", 99, "ff", 88);
1323 if (expectEvolved) {
1324 checkRawFields(obj.getSuper());
1326 checkRawFields(obj.getSuper(), "f", 123, "skey", 456);
1327 checkRawFields(obj.getSuper().getSuper());
1329 Environment env = store.getEnvironment();
1330 assertDbExists(!expectEvolved, env, NAME2, "skey");
1335 static class DeleteSuperclass4_BaseClass
1336 extends EvolveCase {
1340 * Allow deleting a superclass from the hierarchy when the superclass
1341 * has NO persistent fields. No mutations are needed.
1344 static class DeleteSuperclass4_NoFields extends EvolveCase {
1346 private static final String NAME =
1347 DeleteSuperclass4_BaseClass.class.getName();
1348 private static final String NAME2 =
1349 DeleteSuperclass4_NoFields.class.getName();
1357 void checkEvolvedModel(EntityModel model,
1359 boolean oldTypesExist) {
1360 checkEntity(true, model, env, NAME2, 1, null);
1361 if (oldTypesExist) {
1362 checkVersions(model, NAME2, 1, NAME2, 0);
1363 checkNonEntity(true, model, env, NAME, 0);
1364 checkVersions(model, NAME, 0);
1366 checkVersions(model, NAME2, 1);
1371 void readObjects(EntityStore store, boolean doUpdate)
1372 throws DatabaseException {
1374 PrimaryIndex<Integer, DeleteSuperclass4_NoFields>
1375 index = store.getPrimaryIndex
1377 DeleteSuperclass4_NoFields.class);
1378 DeleteSuperclass4_NoFields obj = index.get(key);
1379 TestCase.assertNotNull(obj);
1381 (EvolveCase.class, obj.getClass().getSuperclass());
1382 TestCase.assertEquals(99, obj.key);
1383 TestCase.assertEquals(88, obj.ff);
1390 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1391 throws DatabaseException {
1393 PrimaryIndex<Integer, DeleteSuperclass4_NoFields>
1394 index = newStore.getPrimaryIndex
1396 DeleteSuperclass4_NoFields.class);
1397 RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1398 index.put((DeleteSuperclass4_NoFields)
1399 newStore.getModel().convertRawObject(raw));
1403 void readRawObjects(RawStore store,
1404 boolean expectEvolved,
1405 boolean expectUpdated)
1406 throws DatabaseException {
1409 if (expectEvolved) {
1410 obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1412 obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1414 checkRawFields(obj, "key", 99, "ff", 88);
1415 checkRawFields(obj.getSuper());
1416 if (expectEvolved) {
1417 TestCase.assertNull(obj.getSuper().getSuper());
1419 checkRawFields(obj.getSuper().getSuper());
1424 @Persistent(version=1)
1425 static class DeleteSuperclass5_Embedded {
1430 public String toString() {
1436 * Ensure that a superclass at the top of the hierarchy can be deleted. A
1437 * class Deleter is used.
1440 static class DeleteSuperclass5_Top
1441 extends EvolveCase {
1443 private static final String NAME =
1444 DeleteSuperclass5_Top.class.getName();
1445 private static final String NAME2 =
1446 DeleteSuperclass5_Embedded.class.getName();
1447 private static final String NAME3 =
1448 PREFIX + "DeleteSuperclass5_Embedded_Base";
1455 DeleteSuperclass5_Embedded embed =
1456 new DeleteSuperclass5_Embedded();
1459 Mutations getMutations() {
1460 Mutations m = new Mutations();
1461 m.addDeleter(new Deleter(NAME3, 0));
1466 void checkEvolvedModel(EntityModel model,
1468 boolean oldTypesExist) {
1469 checkEntity(true, model, env, NAME, 0, null);
1470 checkNonEntity(true, model, env, NAME2, 1);
1471 checkNonEntity(false, model, env, NAME3, 0);
1472 checkVersions(model, NAME, 0);
1473 if (oldTypesExist) {
1474 checkVersions(model, NAME2, 1, NAME2, 0);
1475 checkVersions(model, NAME3, 0);
1477 checkVersions(model, NAME2, 1);
1482 void readObjects(EntityStore store, boolean doUpdate)
1483 throws DatabaseException {
1485 PrimaryIndex<Integer, DeleteSuperclass5_Top>
1486 index = store.getPrimaryIndex
1488 DeleteSuperclass5_Top.class);
1489 DeleteSuperclass5_Top obj = index.get(key);
1490 TestCase.assertNotNull(obj);
1491 TestCase.assertNotNull(obj.embed);
1492 TestCase.assertEquals(99, obj.key);
1493 TestCase.assertEquals(88, obj.ff);
1494 TestCase.assertEquals(123, obj.embed.f);
1501 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1502 throws DatabaseException {
1504 PrimaryIndex<Integer, DeleteSuperclass5_Top>
1505 index = newStore.getPrimaryIndex
1507 DeleteSuperclass5_Top.class);
1508 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
1509 index.put((DeleteSuperclass5_Top)
1510 newStore.getModel().convertRawObject(raw));
1514 void readRawObjects(RawStore store,
1515 boolean expectEvolved,
1516 boolean expectUpdated)
1517 throws DatabaseException {
1519 RawType embedType = store.getModel().getRawType(NAME2);
1520 RawObject embedSuper = null;
1521 if (!expectEvolved) {
1522 RawType embedSuperType = store.getModel().getRawType(NAME3);
1523 embedSuper = new RawObject
1524 (embedSuperType, makeValues("g", 456), null);
1527 new RawObject(embedType, makeValues("f", 123), embedSuper);
1528 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1529 checkRawFields(obj, "key", 99, "ff", 88, "embed", embed);
1534 static class InsertSuperclass1_BaseClass
1535 extends EvolveCase {
1541 * Allow inserting a superclass between two existing classes in the
1542 * hierarchy. No mutations are needed.
1545 static class InsertSuperclass1_Between
1546 extends InsertSuperclass1_BaseClass {
1548 private static final String NAME =
1549 InsertSuperclass1_BaseClass.class.getName();
1550 private static final String NAME2 =
1551 InsertSuperclass1_Between.class.getName();
1559 void checkEvolvedModel(EntityModel model,
1561 boolean oldTypesExist) {
1562 checkNonEntity(true, model, env, NAME, 0);
1563 checkEntity(true, model, env, NAME2, 1, null);
1564 checkVersions(model, NAME, 0);
1565 if (oldTypesExist) {
1566 checkVersions(model, NAME2, 1, NAME2, 0);
1568 checkVersions(model, NAME2, 1);
1573 void readObjects(EntityStore store, boolean doUpdate)
1574 throws DatabaseException {
1576 PrimaryIndex<Integer, InsertSuperclass1_Between>
1577 index = store.getPrimaryIndex
1579 InsertSuperclass1_Between.class);
1580 InsertSuperclass1_Between obj = index.get(key);
1581 TestCase.assertNotNull(obj);
1583 (InsertSuperclass1_BaseClass.class,
1584 obj.getClass().getSuperclass());
1587 obj.getClass().getSuperclass().getSuperclass());
1588 TestCase.assertEquals(99, obj.key);
1589 TestCase.assertEquals(88, obj.ff);
1590 TestCase.assertEquals(123, obj.f);
1597 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1598 throws DatabaseException {
1600 PrimaryIndex<Integer, InsertSuperclass1_Between>
1601 index = newStore.getPrimaryIndex
1603 InsertSuperclass1_Between.class);
1604 RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1605 index.put((InsertSuperclass1_Between)
1606 newStore.getModel().convertRawObject(raw));
1610 void readRawObjects(RawStore store,
1611 boolean expectEvolved,
1612 boolean expectUpdated)
1613 throws DatabaseException {
1616 if (expectEvolved) {
1617 obj = readRaw(store, 99, NAME2, 1, NAME, 0, CASECLS, 0);
1619 obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
1621 checkRawFields(obj, "key", 99, "ff", 88);
1622 if (expectEvolved) {
1623 if (expectUpdated) {
1624 checkRawFields(obj.getSuper(), "f", 123);
1626 checkRawFields(obj.getSuper());
1628 checkRawFields(obj.getSuper().getSuper());
1629 TestCase.assertNull(obj.getSuper().getSuper().getSuper());
1631 checkRawFields(obj.getSuper());
1632 TestCase.assertNull(obj.getSuper().getSuper());
1638 static class InsertSuperclass2_Embedded_Base {
1643 @Persistent(version=1)
1644 static class InsertSuperclass2_Embedded
1645 extends InsertSuperclass2_Embedded_Base {
1651 * Allow inserting a superclass at the top of the hierarchy. No mutations
1655 static class InsertSuperclass2_Top
1656 extends EvolveCase {
1658 private static final String NAME =
1659 InsertSuperclass2_Top.class.getName();
1660 private static final String NAME2 =
1661 InsertSuperclass2_Embedded.class.getName();
1662 private static final String NAME3 =
1663 InsertSuperclass2_Embedded_Base.class.getName();
1670 InsertSuperclass2_Embedded embed =
1671 new InsertSuperclass2_Embedded();
1674 void checkEvolvedModel(EntityModel model,
1676 boolean oldTypesExist) {
1677 checkEntity(true, model, env, NAME, 0, null);
1678 checkNonEntity(true, model, env, NAME2, 1);
1679 checkNonEntity(true, model, env, NAME3, 0);
1680 checkVersions(model, NAME, 0);
1681 if (oldTypesExist) {
1682 checkVersions(model, NAME2, 1, NAME2, 0);
1684 checkVersions(model, NAME2, 1);
1686 checkVersions(model, NAME3, 0);
1690 void readObjects(EntityStore store, boolean doUpdate)
1691 throws DatabaseException {
1693 PrimaryIndex<Integer, InsertSuperclass2_Top>
1694 index = store.getPrimaryIndex
1696 InsertSuperclass2_Top.class);
1697 InsertSuperclass2_Top obj = index.get(key);
1698 TestCase.assertNotNull(obj);
1699 TestCase.assertNotNull(obj.embed);
1700 TestCase.assertEquals(99, obj.key);
1701 TestCase.assertEquals(88, obj.ff);
1702 TestCase.assertEquals(123, obj.embed.f);
1703 TestCase.assertEquals(456, obj.embed.g);
1710 void copyRawObjects(RawStore rawStore, EntityStore newStore)
1711 throws DatabaseException {
1713 PrimaryIndex<Integer, InsertSuperclass2_Top>
1714 index = newStore.getPrimaryIndex
1716 InsertSuperclass2_Top.class);
1717 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
1718 index.put((InsertSuperclass2_Top)
1719 newStore.getModel().convertRawObject(raw));
1723 void readRawObjects(RawStore store,
1724 boolean expectEvolved,
1725 boolean expectUpdated)
1726 throws DatabaseException {
1728 RawType embedType = store.getModel().getRawType(NAME2);
1729 RawObject embedSuper = null;
1730 if (expectEvolved) {
1731 RawType embedSuperType = store.getModel().getRawType(NAME3);
1732 Map<String, Object> values =
1733 expectUpdated ? makeValues("g", 456) : makeValues();
1734 embedSuper = new RawObject(embedSuperType, values, null);
1737 new RawObject(embedType, makeValues("f", 123), embedSuper);
1738 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1739 checkRawFields(obj, "key", 99, "ff", 88, "embed", embed);
1744 static class DisallowNonKeyField_PrimitiveToObject
1745 extends EvolveCase {
1747 private static final String NAME =
1748 DisallowNonKeyField_PrimitiveToObject.class.getName();
1756 public String getStoreOpenException() {
1757 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_PrimitiveToObject version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_PrimitiveToObject version: 1 Error: Old field type: int is not compatible with the new type: java.lang.String for field: ff";
1761 void checkUnevolvedModel(EntityModel model, Environment env) {
1762 checkEntity(true, model, env, NAME, 0, null);
1763 checkVersions(model, NAME, 0);
1767 void readRawObjects(RawStore store,
1768 boolean expectEvolved,
1769 boolean expectUpdated)
1770 throws DatabaseException {
1772 if (expectEvolved) {
1775 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1776 checkRawFields(obj, "key", 99, "ff", 88);
1781 static class DisallowNonKeyField_ObjectToPrimitive
1782 extends EvolveCase {
1784 private static final String NAME =
1785 DisallowNonKeyField_ObjectToPrimitive.class.getName();
1793 public String getStoreOpenException() {
1794 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToPrimitive version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToPrimitive version: 1 Error: Old field type: java.lang.String is not compatible with the new type: int for field: ff";
1798 void checkUnevolvedModel(EntityModel model, Environment env) {
1799 checkEntity(true, model, env, NAME, 0, null);
1800 checkVersions(model, NAME, 0);
1804 void readRawObjects(RawStore store,
1805 boolean expectEvolved,
1806 boolean expectUpdated)
1807 throws DatabaseException {
1809 if (expectEvolved) {
1812 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1813 checkRawFields(obj, "key", 99, "ff", "88");
1818 static class MyType {
1821 public boolean equals(Object o) {
1822 return o instanceof MyType;
1827 static class MySubtype extends MyType {
1830 public boolean equals(Object o) {
1831 return o instanceof MySubtype;
1836 static class DisallowNonKeyField_ObjectToSubtype
1837 extends EvolveCase {
1839 private static final String NAME =
1840 DisallowNonKeyField_ObjectToSubtype.class.getName();
1848 public String getStoreOpenException() {
1849 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToSubtype version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToSubtype version: 1 Error: Old field type: com.sleepycat.persist.test.EvolveClasses$MyType is not compatible with the new type: com.sleepycat.persist.test.EvolveClasses$MySubtype for field: ff";
1853 void checkUnevolvedModel(EntityModel model, Environment env) {
1854 checkEntity(true, model, env, NAME, 0, null);
1855 checkVersions(model, NAME, 0);
1859 void readRawObjects(RawStore store,
1860 boolean expectEvolved,
1861 boolean expectUpdated)
1862 throws DatabaseException {
1864 if (expectEvolved) {
1867 RawType embedType = store.getModel().getRawType
1868 (MyType.class.getName());
1869 RawObject embed = new RawObject(embedType, makeValues(), null);
1871 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1872 checkRawFields(obj, "key", 99, "ff", embed);
1877 static class DisallowNonKeyField_ObjectToUnrelatedSimple
1878 extends EvolveCase {
1880 private static final String NAME =
1881 DisallowNonKeyField_ObjectToUnrelatedSimple.class.getName();
1889 public String getStoreOpenException() {
1890 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedSimple version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedSimple version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: java.lang.String for field: ff";
1894 void checkUnevolvedModel(EntityModel model, Environment env) {
1895 checkEntity(true, model, env, NAME, 0, null);
1896 checkVersions(model, NAME, 0);
1900 void readRawObjects(RawStore store,
1901 boolean expectEvolved,
1902 boolean expectUpdated)
1903 throws DatabaseException {
1905 if (expectEvolved) {
1908 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1909 checkRawFields(obj, "key", 99, "ff", 88);
1914 static class DisallowNonKeyField_ObjectToUnrelatedOther
1915 extends EvolveCase {
1917 private static final String NAME =
1918 DisallowNonKeyField_ObjectToUnrelatedOther.class.getName();
1926 public String getStoreOpenException() {
1927 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedOther version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedOther version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: com.sleepycat.persist.test.EvolveClasses$MyType for field: ff";
1931 void checkUnevolvedModel(EntityModel model, Environment env) {
1932 checkEntity(true, model, env, NAME, 0, null);
1933 checkVersions(model, NAME, 0);
1937 void readRawObjects(RawStore store,
1938 boolean expectEvolved,
1939 boolean expectUpdated)
1940 throws DatabaseException {
1942 if (expectEvolved) {
1945 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1946 checkRawFields(obj, "key", 99, "ff", 88);
1951 static class DisallowNonKeyField_byte2boolean
1952 extends EvolveCase {
1954 private static final String NAME =
1955 DisallowNonKeyField_byte2boolean.class.getName();
1963 public String getStoreOpenException() {
1964 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_byte2boolean version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_byte2boolean version: 1 Error: Old field type: byte is not compatible with the new type: boolean for field: ff";
1968 void checkUnevolvedModel(EntityModel model, Environment env) {
1969 checkEntity(true, model, env, NAME, 0, null);
1970 checkVersions(model, NAME, 0);
1974 void readRawObjects(RawStore store,
1975 boolean expectEvolved,
1976 boolean expectUpdated)
1977 throws DatabaseException {
1979 if (expectEvolved) {
1982 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1983 checkRawFields(obj, "key", 99, "ff", (byte) 88);
1988 static class DisallowNonKeyField_short2byte
1989 extends EvolveCase {
1991 private static final String NAME =
1992 DisallowNonKeyField_short2byte.class.getName();
2000 public String getStoreOpenException() {
2001 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_short2byte version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_short2byte version: 1 Error: Old field type: short is not compatible with the new type: byte for field: ff";
2005 void checkUnevolvedModel(EntityModel model, Environment env) {
2006 checkEntity(true, model, env, NAME, 0, null);
2007 checkVersions(model, NAME, 0);
2011 void readRawObjects(RawStore store,
2012 boolean expectEvolved,
2013 boolean expectUpdated)
2014 throws DatabaseException {
2016 if (expectEvolved) {
2019 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2020 checkRawFields(obj, "key", 99, "ff", (short) 88);
2025 static class DisallowNonKeyField_int2short
2026 extends EvolveCase {
2028 private static final String NAME =
2029 DisallowNonKeyField_int2short.class.getName();
2037 public String getStoreOpenException() {
2038 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_int2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_int2short version: 1 Error: Old field type: int is not compatible with the new type: short for field: ff";
2042 void checkUnevolvedModel(EntityModel model, Environment env) {
2043 checkEntity(true, model, env, NAME, 0, null);
2044 checkVersions(model, NAME, 0);
2048 void readRawObjects(RawStore store,
2049 boolean expectEvolved,
2050 boolean expectUpdated)
2051 throws DatabaseException {
2053 if (expectEvolved) {
2056 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2057 checkRawFields(obj, "key", 99, "ff", 88);
2062 static class DisallowNonKeyField_long2int
2063 extends EvolveCase {
2065 private static final String NAME =
2066 DisallowNonKeyField_long2int.class.getName();
2074 public String getStoreOpenException() {
2075 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_long2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_long2int version: 1 Error: Old field type: long is not compatible with the new type: int for field: ff";
2079 void checkUnevolvedModel(EntityModel model, Environment env) {
2080 checkEntity(true, model, env, NAME, 0, null);
2081 checkVersions(model, NAME, 0);
2085 void readRawObjects(RawStore store,
2086 boolean expectEvolved,
2087 boolean expectUpdated)
2088 throws DatabaseException {
2090 if (expectEvolved) {
2093 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2094 checkRawFields(obj, "key", 99, "ff", (long) 88);
2099 static class DisallowNonKeyField_float2long
2100 extends EvolveCase {
2102 private static final String NAME =
2103 DisallowNonKeyField_float2long.class.getName();
2111 public String getStoreOpenException() {
2112 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2long version: 1 Error: Old field type: float is not compatible with the new type: long for field: ff";
2116 void checkUnevolvedModel(EntityModel model, Environment env) {
2117 checkEntity(true, model, env, NAME, 0, null);
2118 checkVersions(model, NAME, 0);
2122 void readRawObjects(RawStore store,
2123 boolean expectEvolved,
2124 boolean expectUpdated)
2125 throws DatabaseException {
2127 if (expectEvolved) {
2130 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2131 checkRawFields(obj, "key", 99, "ff", (float) 88);
2136 static class DisallowNonKeyField_double2float
2137 extends EvolveCase {
2139 private static final String NAME =
2140 DisallowNonKeyField_double2float.class.getName();
2148 public String getStoreOpenException() {
2149 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_double2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_double2float version: 1 Error: Old field type: double is not compatible with the new type: float for field: ff";
2153 void checkUnevolvedModel(EntityModel model, Environment env) {
2154 checkEntity(true, model, env, NAME, 0, null);
2155 checkVersions(model, NAME, 0);
2159 void readRawObjects(RawStore store,
2160 boolean expectEvolved,
2161 boolean expectUpdated)
2162 throws DatabaseException {
2164 if (expectEvolved) {
2167 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2168 checkRawFields(obj, "key", 99, "ff", (double) 88);
2173 static class DisallowNonKeyField_Byte2byte
2174 extends EvolveCase {
2176 private static final String NAME =
2177 DisallowNonKeyField_Byte2byte.class.getName();
2185 public String getStoreOpenException() {
2186 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Byte2byte version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Byte2byte version: 1 Error: Old field type: java.lang.Byte is not compatible with the new type: byte for field: ff";
2190 void checkUnevolvedModel(EntityModel model, Environment env) {
2191 checkEntity(true, model, env, NAME, 0, null);
2192 checkVersions(model, NAME, 0);
2196 void readRawObjects(RawStore store,
2197 boolean expectEvolved,
2198 boolean expectUpdated)
2199 throws DatabaseException {
2201 if (expectEvolved) {
2204 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2205 checkRawFields(obj, "key", 99, "ff", (byte) 88);
2210 static class DisallowNonKeyField_Character2char
2211 extends EvolveCase {
2213 private static final String NAME =
2214 DisallowNonKeyField_Character2char.class.getName();
2222 public String getStoreOpenException() {
2223 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Character2char version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Character2char version: 1 Error: Old field type: java.lang.Character is not compatible with the new type: char for field: ff";
2227 void checkUnevolvedModel(EntityModel model, Environment env) {
2228 checkEntity(true, model, env, NAME, 0, null);
2229 checkVersions(model, NAME, 0);
2233 void readRawObjects(RawStore store,
2234 boolean expectEvolved,
2235 boolean expectUpdated)
2236 throws DatabaseException {
2238 if (expectEvolved) {
2241 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2242 checkRawFields(obj, "key", 99, "ff", (char) 88);
2247 static class DisallowNonKeyField_Short2short
2248 extends EvolveCase {
2250 private static final String NAME =
2251 DisallowNonKeyField_Short2short.class.getName();
2259 public String getStoreOpenException() {
2260 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Short2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Short2short version: 1 Error: Old field type: java.lang.Short is not compatible with the new type: short for field: ff";
2264 void checkUnevolvedModel(EntityModel model, Environment env) {
2265 checkEntity(true, model, env, NAME, 0, null);
2266 checkVersions(model, NAME, 0);
2270 void readRawObjects(RawStore store,
2271 boolean expectEvolved,
2272 boolean expectUpdated)
2273 throws DatabaseException {
2275 if (expectEvolved) {
2278 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2279 checkRawFields(obj, "key", 99, "ff", (short) 88);
2284 static class DisallowNonKeyField_Integer2int
2285 extends EvolveCase {
2287 private static final String NAME =
2288 DisallowNonKeyField_Integer2int.class.getName();
2296 public String getStoreOpenException() {
2297 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Integer2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Integer2int version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: int for field: ff";
2301 void checkUnevolvedModel(EntityModel model, Environment env) {
2302 checkEntity(true, model, env, NAME, 0, null);
2303 checkVersions(model, NAME, 0);
2307 void readRawObjects(RawStore store,
2308 boolean expectEvolved,
2309 boolean expectUpdated)
2310 throws DatabaseException {
2312 if (expectEvolved) {
2315 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2316 checkRawFields(obj, "key", 99, "ff", 88);
2321 static class DisallowNonKeyField_Long2long
2322 extends EvolveCase {
2324 private static final String NAME =
2325 DisallowNonKeyField_Long2long.class.getName();
2333 public String getStoreOpenException() {
2334 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Long2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Long2long version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: long for field: ff";
2338 void checkUnevolvedModel(EntityModel model, Environment env) {
2339 checkEntity(true, model, env, NAME, 0, null);
2340 checkVersions(model, NAME, 0);
2344 void readRawObjects(RawStore store,
2345 boolean expectEvolved,
2346 boolean expectUpdated)
2347 throws DatabaseException {
2349 if (expectEvolved) {
2352 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2353 checkRawFields(obj, "key", 99, "ff", (long) 88);
2358 static class DisallowNonKeyField_Float2float
2359 extends EvolveCase {
2361 private static final String NAME =
2362 DisallowNonKeyField_Float2float.class.getName();
2370 public String getStoreOpenException() {
2371 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Float2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Float2float version: 1 Error: Old field type: java.lang.Float is not compatible with the new type: float for field: ff";
2375 void checkUnevolvedModel(EntityModel model, Environment env) {
2376 checkEntity(true, model, env, NAME, 0, null);
2377 checkVersions(model, NAME, 0);
2381 void readRawObjects(RawStore store,
2382 boolean expectEvolved,
2383 boolean expectUpdated)
2384 throws DatabaseException {
2386 if (expectEvolved) {
2389 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2390 checkRawFields(obj, "key", 99, "ff", (float) 88);
2395 static class DisallowNonKeyField_Double2double
2396 extends EvolveCase {
2398 private static final String NAME =
2399 DisallowNonKeyField_Double2double.class.getName();
2407 public String getStoreOpenException() {
2408 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Double2double version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Double2double version: 1 Error: Old field type: java.lang.Double is not compatible with the new type: double for field: ff";
2412 void checkUnevolvedModel(EntityModel model, Environment env) {
2413 checkEntity(true, model, env, NAME, 0, null);
2414 checkVersions(model, NAME, 0);
2418 void readRawObjects(RawStore store,
2419 boolean expectEvolved,
2420 boolean expectUpdated)
2421 throws DatabaseException {
2423 if (expectEvolved) {
2426 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2427 checkRawFields(obj, "key", 99, "ff", (double) 88);
2432 static class DisallowNonKeyField_float2BigInt
2433 extends EvolveCase {
2435 private static final String NAME =
2436 DisallowNonKeyField_float2BigInt.class.getName();
2444 public String getStoreOpenException() {
2445 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2BigInt version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2BigInt version: 1 Error: Old field type: float is not compatible with the new type: java.math.BigInteger for field: ff";
2449 void checkUnevolvedModel(EntityModel model, Environment env) {
2450 checkEntity(true, model, env, NAME, 0, null);
2451 checkVersions(model, NAME, 0);
2455 void readRawObjects(RawStore store,
2456 boolean expectEvolved,
2457 boolean expectUpdated)
2458 throws DatabaseException {
2460 if (expectEvolved) {
2463 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2464 checkRawFields(obj, "key", 99, "ff", (float) 88);
2469 static class DisallowNonKeyField_BigInt2long
2470 extends EvolveCase {
2472 private static final String NAME =
2473 DisallowNonKeyField_BigInt2long.class.getName();
2481 public String getStoreOpenException() {
2482 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_BigInt2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_BigInt2long version: 1 Error: Old field type: java.math.BigInteger is not compatible with the new type: long for field: ff";
2486 void checkUnevolvedModel(EntityModel model, Environment env) {
2487 checkEntity(true, model, env, NAME, 0, null);
2488 checkVersions(model, NAME, 0);
2492 void readRawObjects(RawStore store,
2493 boolean expectEvolved,
2494 boolean expectUpdated)
2495 throws DatabaseException {
2497 if (expectEvolved) {
2500 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2501 checkRawFields(obj, "key", 99, "ff", BigInteger.valueOf(88));
2506 static class DisallowSecKeyField_byte2short
2507 extends EvolveCase {
2509 private static final String NAME =
2510 DisallowSecKeyField_byte2short.class.getName();
2515 @SecondaryKey(relate=ONE_TO_ONE)
2519 public String getStoreOpenException() {
2520 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_byte2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_byte2short version: 1 Error: Old field type: byte is not compatible with the new type: short for field: ff";
2524 void checkUnevolvedModel(EntityModel model, Environment env) {
2525 checkEntity(true, model, env, NAME, 0, "ff");
2526 checkVersions(model, NAME, 0);
2530 void readRawObjects(RawStore store,
2531 boolean expectEvolved,
2532 boolean expectUpdated)
2533 throws DatabaseException {
2535 if (expectEvolved) {
2538 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2539 checkRawFields(obj, "key", 99, "ff", (byte) 88);
2544 static class DisallowSecKeyField_char2int
2545 extends EvolveCase {
2547 private static final String NAME =
2548 DisallowSecKeyField_char2int.class.getName();
2553 @SecondaryKey(relate=ONE_TO_ONE)
2557 public String getStoreOpenException() {
2558 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_char2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_char2int version: 1 Error: Old field type: char is not compatible with the new type: int for field: ff";
2562 void checkUnevolvedModel(EntityModel model, Environment env) {
2563 checkEntity(true, model, env, NAME, 0, "ff");
2564 checkVersions(model, NAME, 0);
2568 void readRawObjects(RawStore store,
2569 boolean expectEvolved,
2570 boolean expectUpdated)
2571 throws DatabaseException {
2573 if (expectEvolved) {
2576 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2577 checkRawFields(obj, "key", 99, "ff", (char) 88);
2582 static class DisallowSecKeyField_short2int
2583 extends EvolveCase {
2585 private static final String NAME =
2586 DisallowSecKeyField_short2int.class.getName();
2591 @SecondaryKey(relate=ONE_TO_ONE)
2595 public String getStoreOpenException() {
2596 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_short2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_short2int version: 1 Error: Old field type: short is not compatible with the new type: int for field: ff";
2600 void checkUnevolvedModel(EntityModel model, Environment env) {
2601 checkEntity(true, model, env, NAME, 0, "ff");
2602 checkVersions(model, NAME, 0);
2606 void readRawObjects(RawStore store,
2607 boolean expectEvolved,
2608 boolean expectUpdated)
2609 throws DatabaseException {
2611 if (expectEvolved) {
2614 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2615 checkRawFields(obj, "key", 99, "ff", (short) 88);
2620 static class DisallowSecKeyField_int2long
2621 extends EvolveCase {
2623 private static final String NAME =
2624 DisallowSecKeyField_int2long.class.getName();
2629 @SecondaryKey(relate=ONE_TO_ONE)
2633 public String getStoreOpenException() {
2634 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2long version: 1 Error: Old field type: int is not compatible with the new type: long for field: ff";
2638 void checkUnevolvedModel(EntityModel model, Environment env) {
2639 checkEntity(true, model, env, NAME, 0, "ff");
2640 checkVersions(model, NAME, 0);
2644 void readRawObjects(RawStore store,
2645 boolean expectEvolved,
2646 boolean expectUpdated)
2647 throws DatabaseException {
2649 if (expectEvolved) {
2652 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2653 checkRawFields(obj, "key", 99, "ff", 88);
2658 static class DisallowSecKeyField_long2float
2659 extends EvolveCase {
2661 private static final String NAME =
2662 DisallowSecKeyField_long2float.class.getName();
2667 @SecondaryKey(relate=ONE_TO_ONE)
2671 public String getStoreOpenException() {
2672 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_long2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_long2float version: 1 Error: Old field type: long is not compatible with the new type: float for field: ff";
2676 void checkUnevolvedModel(EntityModel model, Environment env) {
2677 checkEntity(true, model, env, NAME, 0, "ff");
2678 checkVersions(model, NAME, 0);
2682 void readRawObjects(RawStore store,
2683 boolean expectEvolved,
2684 boolean expectUpdated)
2685 throws DatabaseException {
2687 if (expectEvolved) {
2690 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2691 checkRawFields(obj, "key", 99, "ff", (long) 88);
2696 static class DisallowSecKeyField_float2double
2697 extends EvolveCase {
2699 private static final String NAME =
2700 DisallowSecKeyField_float2double.class.getName();
2705 @SecondaryKey(relate=ONE_TO_ONE)
2709 public String getStoreOpenException() {
2710 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_float2double version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_float2double version: 1 Error: Old field type: float is not compatible with the new type: double for field: ff";
2714 void checkUnevolvedModel(EntityModel model, Environment env) {
2715 checkEntity(true, model, env, NAME, 0, "ff");
2716 checkVersions(model, NAME, 0);
2720 void readRawObjects(RawStore store,
2721 boolean expectEvolved,
2722 boolean expectUpdated)
2723 throws DatabaseException {
2725 if (expectEvolved) {
2728 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2729 checkRawFields(obj, "key", 99, "ff", (float) 88);
2734 static class DisallowSecKeyField_Byte2short2
2735 extends EvolveCase {
2737 private static final String NAME =
2738 DisallowSecKeyField_Byte2short2.class.getName();
2743 @SecondaryKey(relate=ONE_TO_ONE)
2747 public String getStoreOpenException() {
2748 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Byte2short2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Byte2short2 version: 1 Error: Old field type: java.lang.Byte is not compatible with the new type: short for field: ff";
2752 void checkUnevolvedModel(EntityModel model, Environment env) {
2753 checkEntity(true, model, env, NAME, 0, "ff");
2754 checkVersions(model, NAME, 0);
2758 void readRawObjects(RawStore store,
2759 boolean expectEvolved,
2760 boolean expectUpdated)
2761 throws DatabaseException {
2763 if (expectEvolved) {
2766 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2767 checkRawFields(obj, "key", 99, "ff", (byte) 88);
2772 static class DisallowSecKeyField_Character2int
2773 extends EvolveCase {
2775 private static final String NAME =
2776 DisallowSecKeyField_Character2int.class.getName();
2781 @SecondaryKey(relate=ONE_TO_ONE)
2785 public String getStoreOpenException() {
2786 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Character2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Character2int version: 1 Error: Old field type: java.lang.Character is not compatible with the new type: int for field: ff";
2790 void checkUnevolvedModel(EntityModel model, Environment env) {
2791 checkEntity(true, model, env, NAME, 0, "ff");
2792 checkVersions(model, NAME, 0);
2796 void readRawObjects(RawStore store,
2797 boolean expectEvolved,
2798 boolean expectUpdated)
2799 throws DatabaseException {
2801 if (expectEvolved) {
2804 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2805 checkRawFields(obj, "key", 99, "ff", (char) 88);
2810 static class DisallowSecKeyField_Short2int2
2811 extends EvolveCase {
2813 private static final String NAME =
2814 DisallowSecKeyField_Short2int2.class.getName();
2819 @SecondaryKey(relate=ONE_TO_ONE)
2823 public String getStoreOpenException() {
2824 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Short2int2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Short2int2 version: 1 Error: Old field type: java.lang.Short is not compatible with the new type: int for field: ff";
2828 void checkUnevolvedModel(EntityModel model, Environment env) {
2829 checkEntity(true, model, env, NAME, 0, "ff");
2830 checkVersions(model, NAME, 0);
2834 void readRawObjects(RawStore store,
2835 boolean expectEvolved,
2836 boolean expectUpdated)
2837 throws DatabaseException {
2839 if (expectEvolved) {
2842 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2843 checkRawFields(obj, "key", 99, "ff", (short) 88);
2848 static class DisallowSecKeyField_Integer2long
2849 extends EvolveCase {
2851 private static final String NAME =
2852 DisallowSecKeyField_Integer2long.class.getName();
2857 @SecondaryKey(relate=ONE_TO_ONE)
2861 public String getStoreOpenException() {
2862 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Integer2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Integer2long version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: long for field: ff";
2866 void checkUnevolvedModel(EntityModel model, Environment env) {
2867 checkEntity(true, model, env, NAME, 0, "ff");
2868 checkVersions(model, NAME, 0);
2872 void readRawObjects(RawStore store,
2873 boolean expectEvolved,
2874 boolean expectUpdated)
2875 throws DatabaseException {
2877 if (expectEvolved) {
2880 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2881 checkRawFields(obj, "key", 99, "ff", 88);
2886 static class DisallowSecKeyField_Long2float2
2887 extends EvolveCase {
2889 private static final String NAME =
2890 DisallowSecKeyField_Long2float2.class.getName();
2895 @SecondaryKey(relate=ONE_TO_ONE)
2899 public String getStoreOpenException() {
2900 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Long2float2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Long2float2 version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: float for field: ff";
2904 void checkUnevolvedModel(EntityModel model, Environment env) {
2905 checkEntity(true, model, env, NAME, 0, "ff");
2906 checkVersions(model, NAME, 0);
2910 void readRawObjects(RawStore store,
2911 boolean expectEvolved,
2912 boolean expectUpdated)
2913 throws DatabaseException {
2915 if (expectEvolved) {
2918 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2919 checkRawFields(obj, "key", 99, "ff", (long) 88);
2924 static class DisallowSecKeyField_Float2double2
2925 extends EvolveCase {
2927 private static final String NAME =
2928 DisallowSecKeyField_Float2double2.class.getName();
2933 @SecondaryKey(relate=ONE_TO_ONE)
2937 public String getStoreOpenException() {
2938 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Float2double2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Float2double2 version: 1 Error: Old field type: java.lang.Float is not compatible with the new type: double for field: ff";
2942 void checkUnevolvedModel(EntityModel model, Environment env) {
2943 checkEntity(true, model, env, NAME, 0, "ff");
2944 checkVersions(model, NAME, 0);
2948 void readRawObjects(RawStore store,
2949 boolean expectEvolved,
2950 boolean expectUpdated)
2951 throws DatabaseException {
2953 if (expectEvolved) {
2956 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2957 checkRawFields(obj, "key", 99, "ff", (float) 88);
2962 static class DisallowSecKeyField_int2BigInt
2963 extends EvolveCase {
2965 private static final String NAME =
2966 DisallowSecKeyField_int2BigInt.class.getName();
2971 @SecondaryKey(relate=ONE_TO_ONE)
2975 public String getStoreOpenException() {
2976 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2BigInt version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2BigInt version: 1 Error: Old field type: int is not compatible with the new type: java.math.BigInteger for field: ff";
2980 void checkUnevolvedModel(EntityModel model, Environment env) {
2981 checkEntity(true, model, env, NAME, 0, "ff");
2982 checkVersions(model, NAME, 0);
2986 void readRawObjects(RawStore store,
2987 boolean expectEvolved,
2988 boolean expectUpdated)
2989 throws DatabaseException {
2991 if (expectEvolved) {
2994 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2995 checkRawFields(obj, "key", 99, "ff", 88);
3002 static class DisallowPriKeyField_byte2short
3003 extends EvolveCase {
3005 private static final String NAME =
3006 DisallowPriKeyField_byte2short.class.getName();
3012 public String getStoreOpenException() {
3013 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_byte2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_byte2short version: 1 Error: Old field type: byte is not compatible with the new type: short for field: key";
3017 void checkUnevolvedModel(EntityModel model, Environment env) {
3018 checkEntity(true, model, env, NAME, 0, null);
3019 checkVersions(model, NAME, 0);
3023 void readRawObjects(RawStore store,
3024 boolean expectEvolved,
3025 boolean expectUpdated)
3026 throws DatabaseException {
3028 if (expectEvolved) {
3031 RawObject obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3032 checkRawFields(obj, "key", (byte) 99);
3037 static class DisallowPriKeyField_char2int
3038 extends EvolveCase {
3040 private static final String NAME =
3041 DisallowPriKeyField_char2int.class.getName();
3047 public String getStoreOpenException() {
3048 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_char2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_char2int version: 1 Error: Old field type: char is not compatible with the new type: int for field: key";
3052 void checkUnevolvedModel(EntityModel model, Environment env) {
3053 checkEntity(true, model, env, NAME, 0, null);
3054 checkVersions(model, NAME, 0);
3058 void readRawObjects(RawStore store,
3059 boolean expectEvolved,
3060 boolean expectUpdated)
3061 throws DatabaseException {
3063 if (expectEvolved) {
3066 RawObject obj = readRaw(store, (char) 99, NAME, 0, CASECLS, 0);
3067 checkRawFields(obj, "key", (char) 99);
3072 static class DisallowPriKeyField_short2int
3073 extends EvolveCase {
3075 private static final String NAME =
3076 DisallowPriKeyField_short2int.class.getName();
3082 public String getStoreOpenException() {
3083 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_short2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_short2int version: 1 Error: Old field type: short is not compatible with the new type: int for field: key";
3087 void checkUnevolvedModel(EntityModel model, Environment env) {
3088 checkEntity(true, model, env, NAME, 0, null);
3089 checkVersions(model, NAME, 0);
3093 void readRawObjects(RawStore store,
3094 boolean expectEvolved,
3095 boolean expectUpdated)
3096 throws DatabaseException {
3098 if (expectEvolved) {
3101 RawObject obj = readRaw(store, (short) 99, NAME, 0, CASECLS, 0);
3102 checkRawFields(obj, "key", (short) 99);
3107 static class DisallowPriKeyField_int2long
3108 extends EvolveCase {
3110 private static final String NAME =
3111 DisallowPriKeyField_int2long.class.getName();
3117 public String getStoreOpenException() {
3118 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_int2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_int2long version: 1 Error: Old field type: int is not compatible with the new type: long for field: key";
3122 void checkUnevolvedModel(EntityModel model, Environment env) {
3123 checkEntity(true, model, env, NAME, 0, null);
3124 checkVersions(model, NAME, 0);
3128 void readRawObjects(RawStore store,
3129 boolean expectEvolved,
3130 boolean expectUpdated)
3131 throws DatabaseException {
3133 if (expectEvolved) {
3136 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
3137 checkRawFields(obj, "key", 99);
3142 static class DisallowPriKeyField_long2float
3143 extends EvolveCase {
3145 private static final String NAME =
3146 DisallowPriKeyField_long2float.class.getName();
3152 public String getStoreOpenException() {
3153 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_long2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_long2float version: 1 Error: Old field type: long is not compatible with the new type: float for field: key";
3157 void checkUnevolvedModel(EntityModel model, Environment env) {
3158 checkEntity(true, model, env, NAME, 0, null);
3159 checkVersions(model, NAME, 0);
3163 void readRawObjects(RawStore store,
3164 boolean expectEvolved,
3165 boolean expectUpdated)
3166 throws DatabaseException {
3168 if (expectEvolved) {
3171 RawObject obj = readRaw(store, (long) 99, NAME, 0, CASECLS, 0);
3172 checkRawFields(obj, "key", (long) 99);
3177 static class DisallowPriKeyField_float2double
3178 extends EvolveCase {
3180 private static final String NAME =
3181 DisallowPriKeyField_float2double.class.getName();
3187 public String getStoreOpenException() {
3188 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_float2double version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_float2double version: 1 Error: Old field type: float is not compatible with the new type: double for field: key";
3192 void checkUnevolvedModel(EntityModel model, Environment env) {
3193 checkEntity(true, model, env, NAME, 0, null);
3194 checkVersions(model, NAME, 0);
3198 void readRawObjects(RawStore store,
3199 boolean expectEvolved,
3200 boolean expectUpdated)
3201 throws DatabaseException {
3203 if (expectEvolved) {
3206 RawObject obj = readRaw(store, (float) 99, NAME, 0, CASECLS, 0);
3207 checkRawFields(obj, "key", (float) 99);
3212 static class DisallowPriKeyField_Byte2short2
3213 extends EvolveCase {
3215 private static final String NAME =
3216 DisallowPriKeyField_Byte2short2.class.getName();
3222 public String getStoreOpenException() {
3223 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Byte2short2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Byte2short2 version: 1 Error: Old field type: java.lang.Byte is not compatible with the new type: short for field: key";
3227 void checkUnevolvedModel(EntityModel model, Environment env) {
3228 checkEntity(true, model, env, NAME, 0, null);
3229 checkVersions(model, NAME, 0);
3233 void readRawObjects(RawStore store,
3234 boolean expectEvolved,
3235 boolean expectUpdated)
3236 throws DatabaseException {
3238 if (expectEvolved) {
3241 RawObject obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3242 checkRawFields(obj, "key", (byte) 99);
3247 static class DisallowPriKeyField_Character2int
3248 extends EvolveCase {
3250 private static final String NAME =
3251 DisallowPriKeyField_Character2int.class.getName();
3257 public String getStoreOpenException() {
3258 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Character2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Character2int version: 1 Error: Old field type: java.lang.Character is not compatible with the new type: int for field: key";
3262 void checkUnevolvedModel(EntityModel model, Environment env) {
3263 checkEntity(true, model, env, NAME, 0, null);
3264 checkVersions(model, NAME, 0);
3268 void readRawObjects(RawStore store,
3269 boolean expectEvolved,
3270 boolean expectUpdated)
3271 throws DatabaseException {
3273 if (expectEvolved) {
3276 RawObject obj = readRaw(store, (char) 99, NAME, 0, CASECLS, 0);
3277 checkRawFields(obj, "key", (char) 99);
3282 static class DisallowPriKeyField_Short2int2
3283 extends EvolveCase {
3285 private static final String NAME =
3286 DisallowPriKeyField_Short2int2.class.getName();
3292 public String getStoreOpenException() {
3293 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Short2int2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Short2int2 version: 1 Error: Old field type: java.lang.Short is not compatible with the new type: int for field: key";
3297 void checkUnevolvedModel(EntityModel model, Environment env) {
3298 checkEntity(true, model, env, NAME, 0, null);
3299 checkVersions(model, NAME, 0);
3303 void readRawObjects(RawStore store,
3304 boolean expectEvolved,
3305 boolean expectUpdated)
3306 throws DatabaseException {
3308 if (expectEvolved) {
3311 RawObject obj = readRaw(store, (short) 99, NAME, 0, CASECLS, 0);
3312 checkRawFields(obj, "key", (short) 99);
3317 static class DisallowPriKeyField_Integer2long
3318 extends EvolveCase {
3320 private static final String NAME =
3321 DisallowPriKeyField_Integer2long.class.getName();
3327 public String getStoreOpenException() {
3328 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Integer2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Integer2long version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: long for field: key";
3332 void checkUnevolvedModel(EntityModel model, Environment env) {
3333 checkEntity(true, model, env, NAME, 0, null);
3334 checkVersions(model, NAME, 0);
3338 void readRawObjects(RawStore store,
3339 boolean expectEvolved,
3340 boolean expectUpdated)
3341 throws DatabaseException {
3343 if (expectEvolved) {
3346 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
3347 checkRawFields(obj, "key", 99);
3352 static class DisallowPriKeyField_Long2float2
3353 extends EvolveCase {
3355 private static final String NAME =
3356 DisallowPriKeyField_Long2float2.class.getName();
3362 public String getStoreOpenException() {
3363 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2float2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2float2 version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: float for field: key";
3367 void checkUnevolvedModel(EntityModel model, Environment env) {
3368 checkEntity(true, model, env, NAME, 0, null);
3369 checkVersions(model, NAME, 0);
3373 void readRawObjects(RawStore store,
3374 boolean expectEvolved,
3375 boolean expectUpdated)
3376 throws DatabaseException {
3378 if (expectEvolved) {
3381 RawObject obj = readRaw(store, (long) 99, NAME, 0, CASECLS, 0);
3382 checkRawFields(obj, "key", (long) 99);
3387 static class DisallowPriKeyField_Float2double2
3388 extends EvolveCase {
3390 private static final String NAME =
3391 DisallowPriKeyField_Float2double2.class.getName();
3397 public String getStoreOpenException() {
3398 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Float2double2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Float2double2 version: 1 Error: Old field type: java.lang.Float is not compatible with the new type: double for field: key";
3402 void checkUnevolvedModel(EntityModel model, Environment env) {
3403 checkEntity(true, model, env, NAME, 0, null);
3404 checkVersions(model, NAME, 0);
3408 void readRawObjects(RawStore store,
3409 boolean expectEvolved,
3410 boolean expectUpdated)
3411 throws DatabaseException {
3413 if (expectEvolved) {
3416 RawObject obj = readRaw(store, (float) 99, NAME, 0, CASECLS, 0);
3417 checkRawFields(obj, "key", (float) 99);
3422 static class DisallowPriKeyField_Long2BigInt
3423 extends EvolveCase {
3425 private static final String NAME =
3426 DisallowPriKeyField_Long2BigInt.class.getName();
3432 public String getStoreOpenException() {
3433 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2BigInt version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2BigInt version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: java.math.BigInteger for field: key";
3437 void checkUnevolvedModel(EntityModel model, Environment env) {
3438 checkEntity(true, model, env, NAME, 0, null);
3439 checkVersions(model, NAME, 0);
3443 void readRawObjects(RawStore store,
3444 boolean expectEvolved,
3445 boolean expectUpdated)
3446 throws DatabaseException {
3448 if (expectEvolved) {
3451 RawObject obj = readRaw(store, 99L, NAME, 0, CASECLS, 0);
3452 checkRawFields(obj, "key", 99L);
3456 @Persistent(version=1)
3457 static class DisallowCompositeKeyField_byte2short_Key {
3470 static class DisallowCompositeKeyField_byte2short
3471 extends EvolveCase {
3473 private static final String NAME =
3474 DisallowCompositeKeyField_byte2short.class.getName();
3475 private static final String NAME2 =
3476 DisallowCompositeKeyField_byte2short_Key.class.getName();
3479 DisallowCompositeKeyField_byte2short_Key key;
3482 public String getStoreOpenException() {
3483 return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowCompositeKeyField_byte2short_Key version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowCompositeKeyField_byte2short_Key version: 1 Error: Old field type: byte is not compatible with the new type: short for field: f2";
3487 void checkUnevolvedModel(EntityModel model, Environment env) {
3488 checkEntity(true, model, env, NAME, 0, null);
3489 checkNonEntity(true, model, env, NAME2, 0);
3490 checkVersions(model, NAME, 0);
3491 checkVersions(model, NAME2, 0);
3495 void readRawObjects(RawStore store,
3496 boolean expectEvolved,
3497 boolean expectUpdated)
3498 throws DatabaseException {
3500 if (expectEvolved) {
3503 RawType rawKeyType = store.getModel().getRawType(NAME2);
3504 RawObject rawKey = new RawObject
3506 makeValues("f1", 1, "f2", (byte) 2, "f3", "3"),
3509 RawObject obj = readRaw(store, rawKey, NAME, 0, CASECLS, 0);
3510 checkRawFields(obj, "key", rawKey);
3515 static class AllowPriKeyField_byte2Byte
3516 extends EvolveCase {
3518 private static final String NAME =
3519 AllowPriKeyField_byte2Byte.class.getName();
3525 void checkEvolvedModel(EntityModel model,
3527 boolean oldTypesExist) {
3528 checkEntity(true, model, env, NAME, 1, null);
3529 if (oldTypesExist) {
3530 checkVersions(model, NAME, 1, NAME, 0);
3532 checkVersions(model, NAME, 1);
3537 void readObjects(EntityStore store, boolean doUpdate)
3538 throws DatabaseException {
3540 PrimaryIndex<Byte, AllowPriKeyField_byte2Byte>
3541 index = store.getPrimaryIndex
3543 AllowPriKeyField_byte2Byte.class);
3544 AllowPriKeyField_byte2Byte obj = index.get(key);
3545 TestCase.assertNotNull(obj);
3546 TestCase.assertEquals(Byte.valueOf((byte) 99), obj.key);
3554 void copyRawObjects(RawStore rawStore, EntityStore newStore)
3555 throws DatabaseException {
3557 PrimaryIndex<Byte, AllowPriKeyField_byte2Byte>
3558 index = newStore.getPrimaryIndex
3560 AllowPriKeyField_byte2Byte.class);
3561 RawObject raw = rawStore.getPrimaryIndex(NAME).get((byte) 99);
3562 index.put((AllowPriKeyField_byte2Byte)
3563 newStore.getModel().convertRawObject(raw));
3567 void readRawObjects(RawStore store,
3568 boolean expectEvolved,
3569 boolean expectUpdated)
3570 throws DatabaseException {
3573 if (expectEvolved) {
3574 obj = readRaw(store, (byte) 99, NAME, 1, CASECLS, 0);
3576 obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3578 checkRawFields(obj, "key", (byte) 99);
3583 static class AllowPriKeyField_Byte2byte2
3584 extends EvolveCase {
3586 private static final String NAME =
3587 AllowPriKeyField_Byte2byte2.class.getName();
3593 void checkEvolvedModel(EntityModel model,
3595 boolean oldTypesExist) {
3596 checkEntity(true, model, env, NAME, 1, null);
3597 if (oldTypesExist) {
3598 checkVersions(model, NAME, 1, NAME, 0);
3600 checkVersions(model, NAME, 1);
3605 void readObjects(EntityStore store, boolean doUpdate)
3606 throws DatabaseException {
3608 PrimaryIndex<Byte, AllowPriKeyField_Byte2byte2>
3609 index = store.getPrimaryIndex
3611 AllowPriKeyField_Byte2byte2.class);
3612 AllowPriKeyField_Byte2byte2 obj = index.get(key);
3613 TestCase.assertNotNull(obj);
3614 TestCase.assertEquals((byte) 99, obj.key);
3622 void copyRawObjects(RawStore rawStore, EntityStore newStore)
3623 throws DatabaseException {
3625 PrimaryIndex<Byte, AllowPriKeyField_Byte2byte2>
3626 index = newStore.getPrimaryIndex
3628 AllowPriKeyField_Byte2byte2.class);
3629 RawObject raw = rawStore.getPrimaryIndex(NAME).get((byte) 99);
3630 index.put((AllowPriKeyField_Byte2byte2)
3631 newStore.getModel().convertRawObject(raw));
3635 void readRawObjects(RawStore store,
3636 boolean expectEvolved,
3637 boolean expectUpdated)
3638 throws DatabaseException {
3641 if (expectEvolved) {
3642 obj = readRaw(store, (byte) 99, NAME, 1, CASECLS, 0);
3644 obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3646 checkRawFields(obj, "key", (byte) 99);
3650 @Persistent(version=1)
3651 static class AllowFieldTypeChanges_Key {
3653 AllowFieldTypeChanges_Key() {
3657 AllowFieldTypeChanges_Key(boolean init) {
3727 @Persistent(version=1)
3728 static class AllowFieldTypeChanges_Base
3729 extends EvolveCase {
3731 @SecondaryKey(relate=ONE_TO_ONE)
3732 AllowFieldTypeChanges_Key kComposite1;
3734 Integer f_long2Integer;
3739 * Allow field type changes: automatic widening, supported widening,
3740 * and Converter mutations. Also tests primary and secondary key field
3744 static class AllowFieldTypeChanges
3745 extends AllowFieldTypeChanges_Base {
3747 private static final String NAME =
3748 AllowFieldTypeChanges.class.getName();
3749 private static final String NAME2 =
3750 AllowFieldTypeChanges_Base.class.getName();
3751 private static final String NAME3 =
3752 AllowFieldTypeChanges_Key.class.getName();
3757 @SecondaryKey(relate=ONE_TO_ONE)
3760 @SecondaryKey(relate=ONE_TO_ONE)
3763 @SecondaryKey(relate=ONE_TO_ONE)
3766 @SecondaryKey(relate=ONE_TO_ONE)
3769 @SecondaryKey(relate=ONE_TO_ONE)
3772 @SecondaryKey(relate=ONE_TO_ONE)
3775 @SecondaryKey(relate=ONE_TO_ONE)
3778 @SecondaryKey(relate=ONE_TO_ONE)
3779 Character kCharacter1;
3856 Mutations getMutations() {
3857 Mutations m = new Mutations();
3858 m.addRenamer(new Renamer(NAME, 0, "pkeyint", "pkeyInt1"));
3859 m.addRenamer(new Renamer(NAME, 0, "kboolean", "kBoolean1"));
3860 m.addRenamer(new Renamer(NAME, 0, "kbyte", "kByte1"));
3861 m.addRenamer(new Renamer(NAME, 0, "kshort", "kShort1"));
3862 m.addRenamer(new Renamer(NAME, 0, "kint", "kInt1"));
3863 m.addRenamer(new Renamer(NAME, 0, "klong", "kLong1"));
3864 m.addRenamer(new Renamer(NAME, 0, "kfloat", "kFloat1"));
3865 m.addRenamer(new Renamer(NAME, 0, "kdouble", "kDouble1"));
3866 m.addRenamer(new Renamer(NAME, 0, "kchar", "kCharacter1"));
3867 m.addRenamer(new Renamer(NAME2, 0, "kcomposite", "kComposite1"));
3869 Conversion conv1 = new MyConversion1();
3870 Conversion conv2 = new MyConversion2();
3872 m.addConverter(new Converter(NAME, 0, "f_long2int", conv1));
3873 m.addConverter(new Converter(NAME, 0, "f_String2long", conv2));
3874 m.addConverter(new Converter(NAME2, 0, "f_long2Integer", conv1));
3875 m.addConverter(new Converter(NAME2, 0, "f_String2Long", conv2));
3879 @SuppressWarnings("serial")
3880 static class MyConversion1 implements Conversion {
3882 public void initialize(EntityModel model) {}
3884 public Object convert(Object o) {
3885 return ((Long) o).intValue();
3889 public boolean equals(Object other) { return true; }
3892 @SuppressWarnings("serial")
3893 static class MyConversion2 implements Conversion {
3895 public void initialize(EntityModel model) {}
3897 public Object convert(Object o) {
3898 return Long.valueOf((String) o);
3902 public boolean equals(Object other) { return true; }
3906 void checkEvolvedModel(EntityModel model,
3908 boolean oldTypesExist) {
3909 checkEntity(true, model, env, NAME, 1, null);
3910 checkNonEntity(true, model, env, NAME2, 1);
3911 if (oldTypesExist) {
3912 checkVersions(model, NAME, 1, NAME, 0);
3913 checkVersions(model, NAME2, 1, NAME2, 0);
3914 checkVersions(model, NAME3, 1, NAME3, 0);
3916 checkVersions(model, NAME, 1);
3917 checkVersions(model, NAME2, 1);
3918 checkVersions(model, NAME3, 1);
3923 void readObjects(EntityStore store, boolean doUpdate)
3924 throws DatabaseException {
3926 PrimaryIndex<Integer, AllowFieldTypeChanges>
3927 index = store.getPrimaryIndex
3928 (Integer.class, AllowFieldTypeChanges.class);
3929 AllowFieldTypeChanges obj = index.get(99);
3931 checkSecondaries(store, index);
3935 checkSecondaries(store, index);
3940 void copyRawObjects(RawStore rawStore, EntityStore newStore)
3941 throws DatabaseException {
3943 PrimaryIndex<Integer, AllowFieldTypeChanges>
3944 index = newStore.getPrimaryIndex
3945 (Integer.class, AllowFieldTypeChanges.class);
3946 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
3947 index.put((AllowFieldTypeChanges)
3948 newStore.getModel().convertRawObject(raw));
3951 private void checkSecondaries(EntityStore store,
3952 PrimaryIndex<Integer,
3953 AllowFieldTypeChanges>
3955 throws DatabaseException {
3957 if (!newMetadataWritten) {
3960 checkValues(store.getSecondaryIndex
3961 (index, Boolean.class, "kBoolean1").get(true));
3962 checkValues(store.getSecondaryIndex
3963 (index, Byte.class, "kByte1").get((byte) 77));
3964 checkValues(store.getSecondaryIndex
3965 (index, Short.class, "kShort1").get((short) 66));
3966 checkValues(store.getSecondaryIndex
3967 (index, Integer.class, "kInt1").get(55));
3968 checkValues(store.getSecondaryIndex
3969 (index, Long.class, "kLong1").get((long) 44));
3970 checkValues(store.getSecondaryIndex
3971 (index, Float.class, "kFloat1").get((float) 33));
3972 checkValues(store.getSecondaryIndex
3973 (index, Double.class, "kDouble1").get((double) 22));
3974 checkValues(store.getSecondaryIndex
3975 (index, Character.class, "kCharacter1").get((char) 11));
3976 checkValues(store.getSecondaryIndex
3977 (index, AllowFieldTypeChanges_Key.class, "kComposite1").get
3978 (new AllowFieldTypeChanges_Key(true)));
3981 private void checkValues(AllowFieldTypeChanges obj) {
3982 TestCase.assertNotNull(obj);
3983 TestCase.assertEquals(obj.pkeyInt1, Integer.valueOf(99));
3984 TestCase.assertEquals(obj.kBoolean1, Boolean.valueOf(true));
3985 TestCase.assertEquals(obj.kByte1, Byte.valueOf((byte) 77));
3986 TestCase.assertEquals(obj.kShort1, Short.valueOf((short) 66));
3987 TestCase.assertEquals(obj.kInt1, Integer.valueOf(55));
3988 TestCase.assertEquals(obj.kLong1, Long.valueOf(44));
3989 TestCase.assertEquals(obj.kFloat1, Float.valueOf(33));
3990 TestCase.assertEquals(obj.kDouble1, Double.valueOf(22));
3991 TestCase.assertEquals(obj.kCharacter1,
3992 Character.valueOf((char) 11));
3994 AllowFieldTypeChanges_Key embed = obj.kComposite1;
3995 TestCase.assertNotNull(embed);
3996 TestCase.assertEquals(embed.f1, true);
3997 TestCase.assertEquals(embed.f2, (byte) 2);
3998 TestCase.assertEquals(embed.f3, (short) 3);
3999 TestCase.assertEquals(embed.f4, 4);
4000 TestCase.assertEquals(embed.f5, 5L);
4001 TestCase.assertEquals(embed.f6, 6F);
4002 TestCase.assertEquals(embed.f7, 7D);
4003 TestCase.assertEquals(embed.f8, (char) 8);
4004 TestCase.assertEquals(embed.f9, Boolean.valueOf(true));
4005 TestCase.assertEquals(embed.f10, Byte.valueOf((byte) 10));
4006 TestCase.assertEquals(embed.f11, Short.valueOf((short) 11));
4007 TestCase.assertEquals(embed.f12, Integer.valueOf(12));
4008 TestCase.assertEquals(embed.f13, Long.valueOf(13L));
4009 TestCase.assertEquals(embed.f14, Float.valueOf(14F));
4010 TestCase.assertEquals(embed.f15, Double.valueOf(15D));
4011 TestCase.assertEquals(embed.f16, Character.valueOf((char) 16));
4013 TestCase.assertEquals(obj.f01, (short) 1);
4014 TestCase.assertEquals(obj.f02, 2);
4015 TestCase.assertEquals(obj.f03, 3);
4016 TestCase.assertEquals(obj.f04, (float) 4);
4017 TestCase.assertEquals(obj.f06, (double) 6);
4018 TestCase.assertEquals(obj.f07, 7);
4019 TestCase.assertEquals(obj.f08, 8);
4020 TestCase.assertEquals(obj.f09, (float) 9);
4021 TestCase.assertEquals(obj.f10, (double) 10);
4022 TestCase.assertEquals(obj.f11, 11);
4023 TestCase.assertEquals(obj.f12, 12);
4024 TestCase.assertEquals(obj.f13, (float) 13);
4025 TestCase.assertEquals(obj.f14, (double) 14);
4026 TestCase.assertEquals(obj.f15, 15L);
4027 TestCase.assertEquals(obj.f16, 16F);
4028 TestCase.assertEquals(obj.f17, 17D);
4029 TestCase.assertEquals(obj.f18, (float) 18);
4030 TestCase.assertEquals(obj.f19, (double) 19);
4031 TestCase.assertEquals(obj.f20, (double) 20);
4033 TestCase.assertEquals(obj.f21, Short.valueOf((byte) 21));
4034 TestCase.assertEquals(obj.f22, Integer.valueOf((byte) 22));
4035 TestCase.assertEquals(obj.f23, Long.valueOf((byte) 23));
4036 TestCase.assertEquals(obj.f24, Float.valueOf((byte) 24));
4037 TestCase.assertEquals(obj.f26, Double.valueOf((byte) 26));
4038 TestCase.assertEquals(obj.f27, Integer.valueOf((short) 27));
4039 TestCase.assertEquals(obj.f28, Long.valueOf((short) 28));
4040 TestCase.assertEquals(obj.f29, Float.valueOf((short) 29));
4041 TestCase.assertEquals(obj.f30, Double.valueOf((short) 30));
4042 TestCase.assertEquals(obj.f31, Integer.valueOf((char) 31));
4043 TestCase.assertEquals(obj.f32, Long.valueOf((char) 32));
4044 TestCase.assertEquals(obj.f33, Float.valueOf((char) 33));
4045 TestCase.assertEquals(obj.f34, Double.valueOf((char) 34));
4046 TestCase.assertEquals(obj.f35, Long.valueOf(35));
4047 TestCase.assertEquals(obj.f36, Float.valueOf(36));
4048 TestCase.assertEquals(obj.f37, Double.valueOf(37));
4049 TestCase.assertEquals(obj.f38, Float.valueOf(38));
4050 TestCase.assertEquals(obj.f39, Double.valueOf(39));
4051 TestCase.assertEquals(obj.f40, Double.valueOf(40));
4053 TestCase.assertEquals(obj.f41, Short.valueOf((byte) 41));
4054 TestCase.assertEquals(obj.f42, Integer.valueOf((byte) 42));
4055 TestCase.assertEquals(obj.f43, Long.valueOf((byte) 43));
4056 TestCase.assertEquals(obj.f44, Float.valueOf((byte) 44));
4057 TestCase.assertEquals(obj.f46, Double.valueOf((byte) 46));
4058 TestCase.assertEquals(obj.f47, Integer.valueOf((short) 47));
4059 TestCase.assertEquals(obj.f48, Long.valueOf((short) 48));
4060 TestCase.assertEquals(obj.f49, Float.valueOf((short) 49));
4061 TestCase.assertEquals(obj.f50, Double.valueOf((short) 50));
4062 TestCase.assertEquals(obj.f51, Integer.valueOf((char) 51));
4063 TestCase.assertEquals(obj.f52, Long.valueOf((char) 52));
4064 TestCase.assertEquals(obj.f53, Float.valueOf((char) 53));
4065 TestCase.assertEquals(obj.f54, Double.valueOf((char) 54));
4066 TestCase.assertEquals(obj.f55, Long.valueOf(55));
4067 TestCase.assertEquals(obj.f56, Float.valueOf(56));
4068 TestCase.assertEquals(obj.f57, Double.valueOf(57));
4069 TestCase.assertEquals(obj.f58, Float.valueOf(58));
4070 TestCase.assertEquals(obj.f59, Double.valueOf(59));
4071 TestCase.assertEquals(obj.f60, Double.valueOf(60));
4073 TestCase.assertEquals(obj.f70, BigInteger.valueOf(70));
4074 TestCase.assertEquals(obj.f71, BigInteger.valueOf(71));
4075 TestCase.assertEquals(obj.f72, BigInteger.valueOf(72));
4076 TestCase.assertEquals(obj.f73, BigInteger.valueOf(73));
4077 TestCase.assertEquals(obj.f74, BigInteger.valueOf(74));
4078 TestCase.assertEquals(obj.f75, BigInteger.valueOf(75));
4079 TestCase.assertEquals(obj.f76, BigInteger.valueOf(76));
4080 TestCase.assertEquals(obj.f77, BigInteger.valueOf(77));
4081 TestCase.assertEquals(obj.f78, BigInteger.valueOf(78));
4082 TestCase.assertEquals(obj.f79, BigInteger.valueOf(79));
4084 TestCase.assertEquals(obj.f_long2Integer, Integer.valueOf(111));
4085 TestCase.assertEquals(obj.f_String2Long, Long.valueOf(222));
4086 TestCase.assertEquals(obj.f_long2int, 333);
4087 TestCase.assertEquals(obj.f_String2long, 444L);
4091 void readRawObjects(RawStore store,
4092 boolean expectEvolved,
4093 boolean expectUpdated)
4094 throws DatabaseException {
4096 RawType embedType = store.getModel().getRawType(NAME3);
4097 RawObject embed = new RawObject
4119 if (expectEvolved) {
4120 obj = readRaw(store, 99, NAME, 1, NAME2, 1, CASECLS, 0);
4121 checkRawFields(obj, "pkeyInt1", 99,
4123 "kByte1", (byte) 77,
4124 "kShort1", (short) 66,
4126 "kLong1", (long) 44,
4127 "kFloat1", (float) 33,
4128 "kDouble1", (double) 22,
4129 "kCharacter1", (char) 11,
4191 "f70", BigInteger.valueOf(70),
4192 "f71", BigInteger.valueOf(71),
4193 "f72", BigInteger.valueOf(72),
4194 "f73", BigInteger.valueOf(73),
4195 "f74", BigInteger.valueOf(74),
4196 "f75", BigInteger.valueOf(75),
4197 "f76", BigInteger.valueOf(76),
4198 "f77", BigInteger.valueOf(77),
4199 "f78", BigInteger.valueOf(78),
4200 "f79", BigInteger.valueOf(79),
4203 "f_String2long", 444L);
4204 checkRawFields(obj.getSuper(),
4205 "kComposite1", embed,
4206 "f_long2Integer", 111,
4207 "f_String2Long", 222L);
4209 obj = readRaw(store, 99, NAME, 0, NAME2, 0, CASECLS, 0);
4210 checkRawFields(obj, "pkeyint", 99,
4213 "kshort", (short) 66,
4216 "kfloat", (float) 33,
4217 "kdouble", (double) 22,
4292 "f_String2long", "444");
4294 checkRawFields(obj.getSuper(),
4295 "kcomposite", embed,
4296 "f_long2Integer", 111L,
4297 "f_String2Long", "222");
4299 Environment env = store.getEnvironment();
4301 assertDbExists(expectEvolved, env, NAME, "kBoolean1");
4302 assertDbExists(expectEvolved, env, NAME, "kByte1");
4303 assertDbExists(expectEvolved, env, NAME, "kShort1");
4304 assertDbExists(expectEvolved, env, NAME, "kInt1");
4305 assertDbExists(expectEvolved, env, NAME, "kLong1");
4306 assertDbExists(expectEvolved, env, NAME, "kFloat1");
4307 assertDbExists(expectEvolved, env, NAME, "kDouble1");
4308 assertDbExists(expectEvolved, env, NAME, "kCharacter1");
4309 assertDbExists(expectEvolved, env, NAME, "kComposite1");
4311 assertDbExists(!expectEvolved, env, NAME, "kboolean");
4312 assertDbExists(!expectEvolved, env, NAME, "kbyte");
4313 assertDbExists(!expectEvolved, env, NAME, "kshort");
4314 assertDbExists(!expectEvolved, env, NAME, "kint");
4315 assertDbExists(!expectEvolved, env, NAME, "klong");
4316 assertDbExists(!expectEvolved, env, NAME, "kfloat");
4317 assertDbExists(!expectEvolved, env, NAME, "kdouble");
4318 assertDbExists(!expectEvolved, env, NAME, "kchar");
4319 assertDbExists(!expectEvolved, env, NAME, "kcomposite");
4323 @SuppressWarnings("serial")
4324 static class ConvertFieldContent_Conversion implements Conversion {
4326 public void initialize(EntityModel model) {
4329 public Object convert(Object fromValue) {
4330 String s1 = (String) fromValue;
4331 return (new StringBuilder(s1)).reverse().toString();
4335 public boolean equals(Object o) {
4336 return o instanceof ConvertFieldContent_Conversion;
4341 static class ConvertFieldContent_Entity
4342 extends EvolveCase {
4344 private static final String NAME =
4345 ConvertFieldContent_Entity.class.getName();
4354 Mutations getMutations() {
4355 Mutations m = new Mutations();
4356 Converter converter = new Converter
4357 (ConvertFieldContent_Entity.class.getName(), 0,
4358 "f1", new ConvertFieldContent_Conversion());
4359 m.addConverter(converter);
4360 converter = new Converter
4361 (ConvertFieldContent_Entity.class.getName(), 0,
4362 "f2", new ConvertFieldContent_Conversion());
4363 m.addConverter(converter);
4368 void checkEvolvedModel(EntityModel model,
4370 boolean oldTypesExist) {
4371 checkEntity(true, model, env, NAME, 1, null);
4372 if (oldTypesExist) {
4373 checkVersions(model, NAME, 1, NAME, 0);
4375 checkVersions(model, NAME, 1);
4380 void readObjects(EntityStore store, boolean doUpdate)
4381 throws DatabaseException {
4383 PrimaryIndex<Integer, ConvertFieldContent_Entity>
4384 index = store.getPrimaryIndex
4386 ConvertFieldContent_Entity.class);
4387 ConvertFieldContent_Entity obj = index.get(99);
4388 TestCase.assertNotNull(obj);
4389 TestCase.assertEquals(99, obj.key);
4390 TestCase.assertEquals("43210", obj.f1);
4391 TestCase.assertEquals("98765", obj.f2);
4399 void copyRawObjects(RawStore rawStore, EntityStore newStore)
4400 throws DatabaseException {
4402 PrimaryIndex<Integer, ConvertFieldContent_Entity>
4403 index = newStore.getPrimaryIndex
4405 ConvertFieldContent_Entity.class);
4406 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4407 index.put((ConvertFieldContent_Entity)
4408 newStore.getModel().convertRawObject(raw));
4412 void readRawObjects(RawStore store,
4413 boolean expectEvolved,
4414 boolean expectUpdated)
4415 throws DatabaseException {
4418 readRaw(store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4419 if (expectEvolved) {
4420 checkRawFields(obj, "key", 99,
4424 checkRawFields(obj, "key", 99,
4431 @Persistent(version=1)
4432 static class ConvertExample1_Address {
4439 @SuppressWarnings("serial")
4440 static class ConvertExample1_Conversion implements Conversion {
4442 public void initialize(EntityModel model) {
4445 public Object convert(Object fromValue) {
4446 return Integer.valueOf((String) fromValue);
4450 public boolean equals(Object o) {
4451 return o instanceof ConvertExample1_Conversion;
4456 static class ConvertExample1_Entity
4457 extends EvolveCase {
4459 private static final String NAME =
4460 ConvertExample1_Entity.class.getName();
4461 private static final String NAME2 =
4462 ConvertExample1_Address.class.getName();
4467 ConvertExample1_Address embed;
4470 Mutations getMutations() {
4471 Mutations m = new Mutations();
4472 Converter converter = new Converter
4473 (ConvertExample1_Address.class.getName(), 0,
4474 "zipCode", new ConvertExample1_Conversion());
4475 m.addConverter(converter);
4480 void checkEvolvedModel(EntityModel model,
4482 boolean oldTypesExist) {
4483 checkEntity(true, model, env, NAME, 0, null);
4484 checkVersions(model, NAME, 0);
4485 if (oldTypesExist) {
4486 checkVersions(model, NAME2, 1, NAME2, 0);
4488 checkVersions(model, NAME2, 1);
4493 void readObjects(EntityStore store, boolean doUpdate)
4494 throws DatabaseException {
4496 PrimaryIndex<Integer, ConvertExample1_Entity>
4497 index = store.getPrimaryIndex
4499 ConvertExample1_Entity.class);
4500 ConvertExample1_Entity obj = index.get(99);
4501 TestCase.assertNotNull(obj);
4502 TestCase.assertEquals(99, obj.key);
4503 TestCase.assertNotNull(obj.embed);
4504 TestCase.assertEquals("street", obj.embed.street);
4505 TestCase.assertEquals("city", obj.embed.city);
4506 TestCase.assertEquals("state", obj.embed.state);
4507 TestCase.assertEquals(12345, obj.embed.zipCode);
4515 void copyRawObjects(RawStore rawStore, EntityStore newStore)
4516 throws DatabaseException {
4518 PrimaryIndex<Integer, ConvertExample1_Entity>
4519 index = newStore.getPrimaryIndex
4521 ConvertExample1_Entity.class);
4522 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4523 index.put((ConvertExample1_Entity)
4524 newStore.getModel().convertRawObject(raw));
4528 void readRawObjects(RawStore store,
4529 boolean expectEvolved,
4530 boolean expectUpdated)
4531 throws DatabaseException {
4533 RawType embedType = store.getModel().getRawType(NAME2);
4535 if (expectEvolved) {
4536 embed = new RawObject
4538 makeValues("street", "street",
4544 embed = new RawObject
4546 makeValues("street", "street",
4549 "zipCode", "12345"),
4552 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
4553 checkRawFields(obj, "key", 99, "embed", embed);
4558 static class ConvertExample2_Address {
4566 static class ConvertExample2_Person
4567 extends EvolveCase {
4569 private static final String NAME =
4570 ConvertExample2_Person.class.getName();
4571 private static final String NAME2 =
4572 ConvertExample2_Address .class.getName();
4577 ConvertExample2_Address address;
4580 Mutations getMutations() {
4581 Mutations m = new Mutations();
4582 Converter converter = new Converter
4583 (ConvertExample2_Person.class.getName(), 0,
4584 "address", new ConvertExample2_Conversion());
4585 m.addConverter(converter);
4590 void checkEvolvedModel(EntityModel model,
4592 boolean oldTypesExist) {
4593 checkEntity(true, model, env, NAME, 1, null);
4594 if (oldTypesExist) {
4595 checkVersions(model, NAME, 1, NAME, 0);
4597 checkVersions(model, NAME, 1);
4599 checkVersions(model, NAME2, 0);
4603 void readObjects(EntityStore store, boolean doUpdate)
4604 throws DatabaseException {
4606 PrimaryIndex<Integer, ConvertExample2_Person>
4607 index = store.getPrimaryIndex
4609 ConvertExample2_Person.class);
4610 ConvertExample2_Person obj = index.get(99);
4611 TestCase.assertNotNull(obj);
4612 TestCase.assertEquals(99, obj.key);
4613 TestCase.assertNotNull(obj.address);
4614 TestCase.assertEquals("street", obj.address.street);
4615 TestCase.assertEquals("city", obj.address.city);
4616 TestCase.assertEquals("state", obj.address.state);
4617 TestCase.assertEquals(12345, obj.address.zipCode);
4625 void copyRawObjects(RawStore rawStore, EntityStore newStore)
4626 throws DatabaseException {
4628 PrimaryIndex<Integer, ConvertExample2_Person>
4629 index = newStore.getPrimaryIndex
4631 ConvertExample2_Person.class);
4632 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4633 index.put((ConvertExample2_Person)
4634 newStore.getModel().convertRawObject(raw));
4638 void readRawObjects(RawStore store,
4639 boolean expectEvolved,
4640 boolean expectUpdated)
4641 throws DatabaseException {
4644 if (expectEvolved) {
4645 RawType embedType = store.getModel().getRawType(NAME2);
4646 embed = new RawObject
4648 makeValues("street", "street",
4654 embed = "street#city#state#12345";
4656 RawObject obj = readRaw
4657 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4658 checkRawFields(obj, "key", 99, "address", embed);
4662 @SuppressWarnings("serial")
4663 static class ConvertExample2_Conversion implements Conversion {
4664 private transient RawType addressType;
4666 public void initialize(EntityModel model) {
4667 addressType = model.getRawType
4668 (ConvertExample2_Address.class.getName());
4671 public Object convert(Object fromValue) {
4673 String oldAddress = (String) fromValue;
4674 Map<String, Object> addressValues = new HashMap<String, Object>();
4675 addressValues.put("street", parseAddress(1, oldAddress));
4676 addressValues.put("city", parseAddress(2, oldAddress));
4677 addressValues.put("state", parseAddress(3, oldAddress));
4678 addressValues.put("zipCode",
4679 Integer.valueOf(parseAddress(4, oldAddress)));
4681 return new RawObject(addressType, addressValues, null);
4685 public boolean equals(Object o) {
4686 return o instanceof ConvertExample2_Conversion;
4689 private String parseAddress(int fieldNum, String oldAddress) {
4690 StringTokenizer tokens = new StringTokenizer(oldAddress, "#");
4691 String field = null;
4692 for (int i = 0; i < fieldNum; i += 1) {
4693 field = tokens.nextToken();
4700 static class ConvertExample3_Address {
4707 @SuppressWarnings("serial")
4708 static class ConvertExample3_Conversion implements Conversion {
4709 private transient RawType newPersonType;
4710 private transient RawType addressType;
4712 public void initialize(EntityModel model) {
4713 newPersonType = model.getRawType
4714 (ConvertExample3_Person.class.getName());
4715 addressType = model.getRawType
4716 (ConvertExample3_Address.class.getName());
4719 public Object convert(Object fromValue) {
4721 RawObject person = (RawObject) fromValue;
4722 Map<String, Object> personValues = person.getValues();
4723 Map<String, Object> addressValues = new HashMap<String, Object>();
4724 RawObject address = new RawObject
4725 (addressType, addressValues, null);
4727 addressValues.put("street", personValues.remove("street"));
4728 addressValues.put("city", personValues.remove("city"));
4729 addressValues.put("state", personValues.remove("state"));
4730 addressValues.put("zipCode", personValues.remove("zipCode"));
4731 personValues.put("address", address);
4733 return new RawObject
4734 (newPersonType, personValues, person.getSuper());
4738 public boolean equals(Object o) {
4739 return o instanceof ConvertExample3_Conversion;
4744 static class ConvertExample3_Person
4745 extends EvolveCase {
4747 private static final String NAME =
4748 ConvertExample3_Person.class.getName();
4749 private static final String NAME2 =
4750 ConvertExample3_Address .class.getName();
4755 ConvertExample3_Address address;
4758 Mutations getMutations() {
4759 Mutations m = new Mutations();
4760 Converter converter = new Converter
4761 (ConvertExample3_Person.class.getName(), 0,
4762 new ConvertExample3_Conversion());
4763 m.addConverter(converter);
4768 void checkEvolvedModel(EntityModel model,
4770 boolean oldTypesExist) {
4771 checkEntity(true, model, env, NAME, 1, null);
4772 if (oldTypesExist) {
4773 checkVersions(model, NAME, 1, NAME, 0);
4775 checkVersions(model, NAME, 1);
4777 checkVersions(model, NAME2, 0);
4781 void readObjects(EntityStore store, boolean doUpdate)
4782 throws DatabaseException {
4784 PrimaryIndex<Integer, ConvertExample3_Person>
4785 index = store.getPrimaryIndex
4787 ConvertExample3_Person.class);
4788 ConvertExample3_Person obj = index.get(99);
4789 TestCase.assertNotNull(obj);
4790 TestCase.assertEquals(99, obj.key);
4791 TestCase.assertNotNull(obj.address);
4792 TestCase.assertEquals("street", obj.address.street);
4793 TestCase.assertEquals("city", obj.address.city);
4794 TestCase.assertEquals("state", obj.address.state);
4795 TestCase.assertEquals(12345, obj.address.zipCode);
4803 void copyRawObjects(RawStore rawStore, EntityStore newStore)
4804 throws DatabaseException {
4806 PrimaryIndex<Integer, ConvertExample3_Person>
4807 index = newStore.getPrimaryIndex
4809 ConvertExample3_Person.class);
4810 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4811 index.put((ConvertExample3_Person)
4812 newStore.getModel().convertRawObject(raw));
4816 void readRawObjects(RawStore store,
4817 boolean expectEvolved,
4818 boolean expectUpdated)
4819 throws DatabaseException {
4821 RawObject obj = readRaw
4822 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4823 if (expectEvolved) {
4824 RawType embedType = store.getModel().getRawType(NAME2);
4825 Object embed = new RawObject
4827 makeValues("street", "street",
4832 checkRawFields(obj, "key", 99, "address", embed);
4834 checkRawFields(obj, "key", 99,
4843 @SuppressWarnings("serial")
4844 static class ConvertExample3Reverse_Conversion implements Conversion {
4845 private transient RawType newPersonType;
4847 public void initialize(EntityModel model) {
4848 newPersonType = model.getRawType
4849 (ConvertExample3Reverse_Person.class.getName());
4852 public Object convert(Object fromValue) {
4854 RawObject person = (RawObject) fromValue;
4855 Map<String, Object> personValues = person.getValues();
4856 RawObject address = (RawObject) personValues.remove("address");
4857 Map<String, Object> addressValues = address.getValues();
4859 personValues.put("street", addressValues.remove("street"));
4860 personValues.put("city", addressValues.remove("city"));
4861 personValues.put("state", addressValues.remove("state"));
4862 personValues.put("zipCode", addressValues.remove("zipCode"));
4864 return new RawObject
4865 (newPersonType, personValues, person.getSuper());
4869 public boolean equals(Object o) {
4870 return o instanceof ConvertExample3Reverse_Conversion;
4875 static class ConvertExample3Reverse_Person
4876 extends EvolveCase {
4878 private static final String NAME =
4879 ConvertExample3Reverse_Person.class.getName();
4880 private static final String NAME2 =
4881 PREFIX + "ConvertExample3Reverse_Address";
4892 Mutations getMutations() {
4893 Mutations m = new Mutations();
4894 Converter converter = new Converter
4895 (ConvertExample3Reverse_Person.class.getName(), 0,
4896 new ConvertExample3Reverse_Conversion());
4897 m.addConverter(converter);
4898 m.addDeleter(new Deleter(NAME2, 0));
4903 void checkEvolvedModel(EntityModel model,
4905 boolean oldTypesExist) {
4906 checkEntity(true, model, env, NAME, 1, null);
4907 if (oldTypesExist) {
4908 checkVersions(model, NAME, 1, NAME, 0);
4909 checkVersions(model, NAME2, 0);
4911 checkVersions(model, NAME, 1);
4916 void readObjects(EntityStore store, boolean doUpdate)
4917 throws DatabaseException {
4919 PrimaryIndex<Integer, ConvertExample3Reverse_Person>
4920 index = store.getPrimaryIndex
4922 ConvertExample3Reverse_Person.class);
4923 ConvertExample3Reverse_Person obj = index.get(99);
4924 TestCase.assertNotNull(obj);
4925 TestCase.assertEquals(99, obj.key);
4926 TestCase.assertEquals("street", obj.street);
4927 TestCase.assertEquals("city", obj.city);
4928 TestCase.assertEquals("state", obj.state);
4929 TestCase.assertEquals(12345, obj.zipCode);
4937 void copyRawObjects(RawStore rawStore, EntityStore newStore)
4938 throws DatabaseException {
4940 PrimaryIndex<Integer, ConvertExample3Reverse_Person>
4941 index = newStore.getPrimaryIndex
4943 ConvertExample3Reverse_Person.class);
4944 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4945 index.put((ConvertExample3Reverse_Person)
4946 newStore.getModel().convertRawObject(raw));
4950 void readRawObjects(RawStore store,
4951 boolean expectEvolved,
4952 boolean expectUpdated)
4953 throws DatabaseException {
4955 RawObject obj = readRaw
4956 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4957 if (expectEvolved) {
4958 checkRawFields(obj, "key", 99,
4964 RawType embedType = store.getModel().getRawType(NAME2);
4965 Object embed = new RawObject
4967 makeValues("street", "street",
4972 checkRawFields(obj, "key", 99, "address", embed);
4977 @Persistent(version=1)
4978 static class ConvertExample4_A extends ConvertExample4_B {
4981 @Persistent(version=1)
4982 static class ConvertExample4_B {
4986 @SuppressWarnings("serial")
4987 static class Example4_Conversion implements Conversion {
4988 private transient RawType newAType;
4989 private transient RawType newBType;
4991 public void initialize(EntityModel model) {
4992 newAType = model.getRawType(ConvertExample4_A.class.getName());
4993 newBType = model.getRawType(ConvertExample4_B.class.getName());
4996 public Object convert(Object fromValue) {
4997 RawObject oldA = (RawObject) fromValue;
4998 RawObject oldB = oldA.getSuper();
4999 Map<String, Object> aValues = oldA.getValues();
5000 Map<String, Object> bValues = oldB.getValues();
5001 bValues.put("name", aValues.remove("name"));
5002 RawObject newB = new RawObject(newBType, bValues, oldB.getSuper());
5003 RawObject newA = new RawObject(newAType, aValues, newB);
5008 public boolean equals(Object o) {
5009 return o instanceof Example4_Conversion;
5014 static class ConvertExample4_Entity
5015 extends EvolveCase {
5017 private static final String NAME =
5018 ConvertExample4_Entity.class.getName();
5019 private static final String NAME2 =
5020 ConvertExample4_A .class.getName();
5021 private static final String NAME3 =
5022 ConvertExample4_B .class.getName();
5027 ConvertExample4_A embed;
5030 Mutations getMutations() {
5031 Mutations m = new Mutations();
5032 Converter converter = new Converter
5033 (ConvertExample4_A.class.getName(), 0,
5034 new Example4_Conversion());
5035 m.addConverter(converter);
5040 void checkEvolvedModel(EntityModel model,
5042 boolean oldTypesExist) {
5043 checkEntity(true, model, env, NAME, 1, null);
5044 if (oldTypesExist) {
5045 checkVersions(model, NAME, 1, NAME, 0);
5046 checkVersions(model, NAME2, 1, NAME2, 0);
5047 checkVersions(model, NAME3, 1, NAME3, 0);
5049 checkVersions(model, NAME, 1);
5050 checkVersions(model, NAME2, 1);
5051 checkVersions(model, NAME3, 1);
5056 void readObjects(EntityStore store, boolean doUpdate)
5057 throws DatabaseException {
5059 PrimaryIndex<Integer, ConvertExample4_Entity>
5060 index = store.getPrimaryIndex
5062 ConvertExample4_Entity.class);
5063 ConvertExample4_Entity obj = index.get(99);
5064 TestCase.assertNotNull(obj);
5065 TestCase.assertEquals(99, obj.key);
5066 TestCase.assertNotNull(obj.embed);
5067 TestCase.assertEquals("name", obj.embed.name);
5075 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5076 throws DatabaseException {
5078 PrimaryIndex<Integer, ConvertExample4_Entity>
5079 index = newStore.getPrimaryIndex
5081 ConvertExample4_Entity.class);
5082 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5083 index.put((ConvertExample4_Entity)
5084 newStore.getModel().convertRawObject(raw));
5088 void readRawObjects(RawStore store,
5089 boolean expectEvolved,
5090 boolean expectUpdated)
5091 throws DatabaseException {
5093 RawType embedTypeA = store.getModel().getRawType(NAME2);
5094 RawType embedTypeB = store.getModel().getRawType(NAME3);
5096 if (expectEvolved) {
5097 embed = new RawObject(embedTypeA, makeValues(),
5099 (embedTypeB, makeValues("name", "name"), null));
5101 embed = new RawObject(embedTypeA, makeValues("name", "name"),
5103 (embedTypeB, makeValues(), null));
5105 RawObject obj = readRaw
5106 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5107 checkRawFields(obj, "key", 99, "embed", embed);
5111 @Persistent(version=1)
5112 static class ConvertExample5_Pet {
5117 static class ConvertExample5_Cat extends ConvertExample5_Pet {
5122 static class ConvertExample5_Dog extends ConvertExample5_Pet {
5126 @SuppressWarnings("serial")
5127 static class ConvertExample5_Conversion implements Conversion {
5128 private transient RawType newPetType;
5129 private transient RawType dogType;
5130 private transient RawType catType;
5132 public void initialize(EntityModel model) {
5133 newPetType = model.getRawType(ConvertExample5_Pet.class.getName());
5134 dogType = model.getRawType(ConvertExample5_Dog.class.getName());
5135 catType = model.getRawType(ConvertExample5_Cat.class.getName());
5138 public Object convert(Object fromValue) {
5139 RawObject pet = (RawObject) fromValue;
5140 Map<String, Object> petValues = pet.getValues();
5141 Map<String, Object> subTypeValues = new HashMap<String, Object>();
5142 Boolean isCat = (Boolean) petValues.remove("isCatNotDog");
5143 Integer finickyLevel = (Integer) petValues.remove("finickyLevel");
5144 Double barkVolume = (Double) petValues.remove("barkVolume");
5147 newSubType = catType;
5148 subTypeValues.put("finickyLevel", finickyLevel);
5150 newSubType = dogType;
5151 subTypeValues.put("barkVolume", barkVolume);
5153 RawObject newPet = new RawObject
5154 (newPetType, petValues, pet.getSuper());
5155 return new RawObject(newSubType, subTypeValues, newPet);
5159 public boolean equals(Object o) {
5160 return o instanceof ConvertExample5_Conversion;
5165 static class ConvertExample5_Entity
5166 extends EvolveCase {
5168 private static final String NAME =
5169 ConvertExample5_Entity.class.getName();
5170 private static final String NAME2 =
5171 ConvertExample5_Pet.class.getName();
5172 private static final String NAME3 =
5173 ConvertExample5_Cat.class.getName();
5174 private static final String NAME4 =
5175 ConvertExample5_Dog.class.getName();
5180 ConvertExample5_Cat cat;
5181 ConvertExample5_Dog dog;
5184 Mutations getMutations() {
5185 Mutations m = new Mutations();
5186 Converter converter = new Converter
5187 (ConvertExample5_Pet.class.getName(), 0,
5188 new ConvertExample5_Conversion());
5189 m.addConverter(converter);
5194 void checkEvolvedModel(EntityModel model,
5196 boolean oldTypesExist) {
5197 checkEntity(true, model, env, NAME, 1, null);
5198 if (oldTypesExist) {
5199 checkVersions(model, NAME, 1, NAME, 0);
5200 checkVersions(model, NAME2, 1, NAME2, 0);
5202 checkVersions(model, NAME, 1);
5203 checkVersions(model, NAME2, 1);
5205 checkVersions(model, NAME3, 0);
5206 checkVersions(model, NAME4, 0);
5210 void readObjects(EntityStore store, boolean doUpdate)
5211 throws DatabaseException {
5213 PrimaryIndex<Integer, ConvertExample5_Entity>
5214 index = store.getPrimaryIndex
5216 ConvertExample5_Entity.class);
5217 ConvertExample5_Entity obj = index.get(99);
5218 TestCase.assertNotNull(obj);
5219 TestCase.assertEquals(99, obj.key);
5220 TestCase.assertNotNull(obj.cat);
5221 TestCase.assertEquals("Jeffry", obj.cat.name);
5222 TestCase.assertEquals(999, obj.cat.finickyLevel);
5223 TestCase.assertNotNull(obj.dog);
5224 TestCase.assertEquals("Nelson", obj.dog.name);
5225 TestCase.assertEquals(0.01, obj.dog.barkVolume);
5233 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5234 throws DatabaseException {
5236 PrimaryIndex<Integer, ConvertExample5_Entity>
5237 index = newStore.getPrimaryIndex
5239 ConvertExample5_Entity.class);
5240 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5241 index.put((ConvertExample5_Entity)
5242 newStore.getModel().convertRawObject(raw));
5246 void readRawObjects(RawStore store,
5247 boolean expectEvolved,
5248 boolean expectUpdated)
5249 throws DatabaseException {
5251 RawType petType = store.getModel().getRawType(NAME2);
5254 if (expectEvolved) {
5255 RawType catType = store.getModel().getRawType(NAME3);
5256 RawType dogType = store.getModel().getRawType(NAME4);
5257 cat = new RawObject(catType, makeValues("finickyLevel", 999),
5258 new RawObject(petType, makeValues("name", "Jeffry"),
5260 dog = new RawObject(dogType, makeValues("barkVolume", 0.01),
5261 new RawObject(petType, makeValues("name", "Nelson"),
5264 cat = new RawObject(petType, makeValues("name", "Jeffry",
5265 "isCatNotDog", true,
5266 "finickyLevel", 999,
5269 dog = new RawObject(petType, makeValues("name", "Nelson",
5270 "isCatNotDog", false,
5272 "barkVolume", 0.01),
5275 RawObject obj = readRaw
5276 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5277 checkRawFields(obj, "key", 99, "cat", cat, "dog", dog);
5281 @Persistent(version=1)
5282 static class AllowFieldAddDelete_Embed {
5283 private final String f0 = "0";
5285 private final int f3 = 3;
5287 private final int f5 = 5;
5288 private final String f8 = "8";
5289 private final int f9 = 9;
5292 @Persistent(version=1)
5293 static class AllowFieldAddDelete_Base
5294 extends EvolveCase {
5296 private final String f0 = "0";
5298 private final int f3 = 3;
5300 private final int f5 = 5;
5301 private final String f8 = "8";
5302 private final int f9 = 9;
5306 static class AllowFieldAddDelete
5307 extends AllowFieldAddDelete_Base {
5309 private static final String NAME =
5310 AllowFieldAddDelete.class.getName();
5311 private static final String NAME2 =
5312 AllowFieldAddDelete_Base.class.getName();
5313 private static final String NAME3 =
5314 AllowFieldAddDelete_Embed.class.getName();
5319 AllowFieldAddDelete_Embed embed;
5321 private final String f0 = "0";
5323 private final int f3 = 3;
5325 private final int f5 = 5;
5326 private final String f8 = "8";
5327 private final int f9 = 9;
5330 Mutations getMutations() {
5331 Mutations m = new Mutations();
5332 for (String name : new String[] {NAME, NAME2, NAME3}) {
5333 m.addDeleter(new Deleter(name, 0, "f1"));
5334 m.addDeleter(new Deleter(name, 0, "f6"));
5335 m.addDeleter(new Deleter(name, 0, "f7"));
5341 void checkEvolvedModel(EntityModel model,
5343 boolean oldTypesExist) {
5344 checkEntity(true, model, env, NAME, 1, null);
5345 if (oldTypesExist) {
5346 checkVersions(model, NAME, 1, NAME, 0);
5347 checkVersions(model, NAME2, 1, NAME2, 0);
5348 checkVersions(model, NAME3, 1, NAME3, 0);
5350 checkVersions(model, NAME, 1);
5351 checkVersions(model, NAME2, 1);
5352 checkVersions(model, NAME3, 1);
5357 void readObjects(EntityStore store, boolean doUpdate)
5358 throws DatabaseException {
5360 PrimaryIndex<Integer, AllowFieldAddDelete>
5361 index = store.getPrimaryIndex
5363 AllowFieldAddDelete.class);
5364 AllowFieldAddDelete obj = index.get(99);
5365 TestCase.assertNotNull(obj);
5366 TestCase.assertEquals(99, obj.key);
5368 AllowFieldAddDelete o = obj;
5370 TestCase.assertNotNull(o);
5371 TestCase.assertEquals("0", o.f0);
5372 TestCase.assertEquals("2", o.f2);
5373 TestCase.assertEquals(3, o.f3);
5374 TestCase.assertEquals("4", o.f4);
5375 TestCase.assertEquals(5, o.f5);
5376 TestCase.assertEquals("8", o.f8);
5377 TestCase.assertEquals(9, o.f9);
5380 AllowFieldAddDelete_Base o = obj;
5382 TestCase.assertNotNull(o);
5383 TestCase.assertEquals("0", o.f0);
5384 TestCase.assertEquals("2", o.f2);
5385 TestCase.assertEquals(3, o.f3);
5386 TestCase.assertEquals("4", o.f4);
5387 TestCase.assertEquals(5, o.f5);
5388 TestCase.assertEquals("8", o.f8);
5389 TestCase.assertEquals(9, o.f9);
5392 AllowFieldAddDelete_Embed o = obj.embed;
5394 TestCase.assertNotNull(o);
5395 TestCase.assertEquals("0", o.f0);
5396 TestCase.assertEquals("2", o.f2);
5397 TestCase.assertEquals(3, o.f3);
5398 TestCase.assertEquals("4", o.f4);
5399 TestCase.assertEquals(5, o.f5);
5400 TestCase.assertEquals("8", o.f8);
5401 TestCase.assertEquals(9, o.f9);
5410 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5411 throws DatabaseException {
5413 PrimaryIndex<Integer, AllowFieldAddDelete>
5414 index = newStore.getPrimaryIndex
5416 AllowFieldAddDelete.class);
5417 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5418 index.put((AllowFieldAddDelete)
5419 newStore.getModel().convertRawObject(raw));
5422 static final Object[] fixedFields0 = {
5430 static final Object[] fixedFields1 = {
5435 static final Object[] fixedFields2 = {
5446 void readRawObjects(RawStore store,
5447 boolean expectEvolved,
5448 boolean expectUpdated)
5449 throws DatabaseException {
5451 RawType baseType = store.getModel().getRawType(NAME2);
5452 RawType embedType = store.getModel().getRawType(NAME3);
5455 if (expectEvolved) {
5456 if (expectUpdated) {
5464 RawObject embed = new RawObject(embedType, makeValues(ff), null);
5465 RawObject obj = readRaw
5466 (store, 99, NAME, expectEvolved ? 1 : 0,
5467 NAME2, expectEvolved ? 1 : 0,
5469 checkRaw(obj, ff, "key", 99, "embed", embed);
5470 checkRaw(obj.getSuper(), ff);
5473 private void checkRaw(RawObject obj,
5474 Object[] fixedFields,
5475 Object... otherFields) {
5476 Object[] allFields =
5477 new Object[otherFields.length + fixedFields.length];
5478 System.arraycopy(otherFields, 0, allFields, 0, otherFields.length);
5479 System.arraycopy(fixedFields, 0, allFields,
5480 otherFields.length, fixedFields.length);
5481 checkRawFields(obj, allFields);
5485 static class ProxiedClass {
5488 ProxiedClass(int data) {
5493 @Persistent(version=1, proxyFor=ProxiedClass.class)
5494 static class ProxiedClass_Proxy implements PersistentProxy<ProxiedClass> {
5497 public void initializeProxy(ProxiedClass o) {
5501 public ProxiedClass convertProxy() {
5502 return new ProxiedClass((int) data);
5507 static class ProxiedClass_Entity
5508 extends EvolveCase {
5510 private static final String NAME =
5511 ProxiedClass_Entity.class.getName();
5512 private static final String NAME2 =
5513 ProxiedClass_Proxy.class.getName();
5521 void configure(EntityModel model, StoreConfig config) {
5522 model.registerClass(ProxiedClass_Proxy.class);
5526 void checkEvolvedModel(EntityModel model,
5528 boolean oldTypesExist) {
5529 checkEntity(true, model, env, NAME, 0, null);
5530 checkVersions(model, NAME, 0);
5531 if (oldTypesExist) {
5532 checkVersions(model, NAME2, 1, NAME2, 0);
5534 checkVersions(model, NAME2, 1);
5539 void readObjects(EntityStore store, boolean doUpdate)
5540 throws DatabaseException {
5542 PrimaryIndex<Integer, ProxiedClass_Entity>
5543 index = store.getPrimaryIndex
5545 ProxiedClass_Entity.class);
5546 ProxiedClass_Entity obj = index.get(99);
5547 TestCase.assertNotNull(obj);
5548 TestCase.assertEquals(99, obj.key);
5549 TestCase.assertNotNull(obj.embed);
5550 TestCase.assertEquals(88, obj.embed.data);
5558 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5559 throws DatabaseException {
5561 PrimaryIndex<Integer, ProxiedClass_Entity>
5562 index = newStore.getPrimaryIndex
5564 ProxiedClass_Entity.class);
5565 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5566 index.put((ProxiedClass_Entity)
5567 newStore.getModel().convertRawObject(raw));
5571 void readRawObjects(RawStore store,
5572 boolean expectEvolved,
5573 boolean expectUpdated)
5574 throws DatabaseException {
5576 RawType embedType = store.getModel().getRawType(NAME2);
5578 if (expectEvolved) {
5579 embed = new RawObject
5580 (embedType, makeValues("data", 88L), null);
5582 embed = new RawObject
5583 (embedType, makeValues("data", 88), null);
5585 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5586 checkRawFields(obj, "key", 99, "embed", embed);
5590 @Persistent(proxyFor=StringBuilder.class)
5591 static class DisallowChangeProxyFor_Proxy2
5592 implements PersistentProxy<StringBuilder> {
5596 public void initializeProxy(StringBuilder o) {
5597 data = o.toString();
5600 public StringBuilder convertProxy() {
5601 return new StringBuilder(data);
5605 @Persistent(proxyFor=StringBuilder.class)
5606 static class DisallowChangeProxyFor_Proxy
5607 implements PersistentProxy<StringBuilder> {
5611 public void initializeProxy(StringBuilder o) {
5612 data = o.toString();
5615 public StringBuilder convertProxy() {
5616 return new StringBuilder(data);
5621 static class DisallowChangeProxyFor
5622 extends EvolveCase {
5628 public String getStoreOpenException() {
5629 return "com.sleepycat.persist.evolve.IncompatibleClassException: Error when evolving class: java.lang.StringBuilder version: 0 to class: java.lang.StringBuilder version: 0 Error: The proxy class for this type has been changed from: com.sleepycat.persist.test.EvolveClasses$DisallowChangeProxyFor_Proxy to: com.sleepycat.persist.test.EvolveClasses$DisallowChangeProxyFor_Proxy2";
5633 void configure(EntityModel model, StoreConfig config) {
5634 //model.registerClass(DisallowChangeProxyFor_Proxy.class);
5635 model.registerClass(DisallowChangeProxyFor_Proxy2.class);
5640 static class DisallowDeleteProxyFor_Proxy {
5645 static class DisallowDeleteProxyFor
5646 extends EvolveCase {
5652 public String getStoreOpenException() {
5653 return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: java.lang.StringBuilder version: 0 Error: java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: java.lang.StringBuilder";
5657 @Persistent(version=1)
5658 static class ArrayNameChange_Component_Renamed {
5664 static class ArrayNameChange_Entity
5665 extends EvolveCase {
5667 private static final String NAME =
5668 ArrayNameChange_Entity.class.getName();
5669 private static final String NAME2 =
5670 ArrayNameChange_Component_Renamed.class.getName();
5671 private static final String NAME3 =
5672 PREFIX + "ArrayNameChange_Component";
5677 ArrayNameChange_Component_Renamed[] embed;
5678 ArrayNameChange_Component_Renamed embed2;
5681 Mutations getMutations() {
5682 Mutations m = new Mutations();
5683 m.addRenamer(new Renamer(NAME3, 0, NAME2));
5688 void checkEvolvedModel(EntityModel model,
5690 boolean oldTypesExist) {
5691 checkEntity(true, model, env, NAME, 0, null);
5692 checkVersions(model, NAME, 0);
5693 if (oldTypesExist) {
5694 checkVersions(model, NAME2, 1, NAME3, 0);
5696 checkVersions(model, NAME2, 1);
5701 void readObjects(EntityStore store, boolean doUpdate)
5702 throws DatabaseException {
5704 PrimaryIndex<Integer, ArrayNameChange_Entity>
5705 index = store.getPrimaryIndex
5707 ArrayNameChange_Entity.class);
5708 ArrayNameChange_Entity obj = index.get(99);
5709 TestCase.assertNotNull(obj);
5710 TestCase.assertEquals(99, obj.key);
5711 TestCase.assertNotNull(obj.embed);
5712 TestCase.assertEquals(1, obj.embed.length);
5713 TestCase.assertEquals(88L, obj.embed[0].data);
5714 TestCase.assertSame(obj.embed2, obj.embed[0]);
5722 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5723 throws DatabaseException {
5725 PrimaryIndex<Integer, ArrayNameChange_Entity>
5726 index = newStore.getPrimaryIndex
5728 ArrayNameChange_Entity.class);
5729 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5730 index.put((ArrayNameChange_Entity)
5731 newStore.getModel().convertRawObject(raw));
5735 void readRawObjects(RawStore store,
5736 boolean expectEvolved,
5737 boolean expectUpdated)
5738 throws DatabaseException {
5740 String compTypeName = expectEvolved ? NAME2 : NAME3;
5741 String arrayTypeName = "[L" + compTypeName + ';';
5742 RawType compType = store.getModel().getRawType(compTypeName);
5743 RawType arrayType = store.getModel().getRawType(arrayTypeName);
5745 if (expectEvolved) {
5746 embed2 = new RawObject
5747 (compType, makeValues("data", 88L), null);
5749 embed2 = new RawObject
5750 (compType, makeValues("data", 88), null);
5752 RawObject embed = new RawObject
5753 (arrayType, new Object[] { embed2 });
5754 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5755 checkRawFields(obj, "key", 99, "embed", embed, "embed2", embed2);
5759 enum AddEnumConstant_Enum {
5764 static class AddEnumConstant_Entity
5765 extends EvolveCase {
5767 private static final String NAME =
5768 AddEnumConstant_Entity.class.getName();
5769 private static final String NAME2 =
5770 AddEnumConstant_Enum.class.getName();
5775 AddEnumConstant_Enum e1;
5776 AddEnumConstant_Enum e2;
5777 AddEnumConstant_Enum e3 = AddEnumConstant_Enum.C;
5780 void checkEvolvedModel(EntityModel model,
5782 boolean oldTypesExist) {
5783 checkEntity(true, model, env, NAME, 1, null);
5784 if (oldTypesExist) {
5785 checkVersions(model, NAME, 1, NAME, 0);
5786 checkVersions(model, NAME2, 0, NAME2, 0);
5788 checkVersions(model, NAME, 1);
5789 checkVersions(model, NAME2, 0);
5794 void readObjects(EntityStore store, boolean doUpdate)
5795 throws DatabaseException {
5797 PrimaryIndex<Integer, AddEnumConstant_Entity>
5798 index = store.getPrimaryIndex
5800 AddEnumConstant_Entity.class);
5801 AddEnumConstant_Entity obj = index.get(99);
5802 TestCase.assertNotNull(obj);
5803 TestCase.assertEquals(99, obj.key);
5804 TestCase.assertSame(AddEnumConstant_Enum.A, obj.e1);
5805 TestCase.assertSame(AddEnumConstant_Enum.B, obj.e2);
5806 TestCase.assertSame(AddEnumConstant_Enum.C, obj.e3);
5814 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5815 throws DatabaseException {
5817 PrimaryIndex<Integer, AddEnumConstant_Entity>
5818 index = newStore.getPrimaryIndex
5820 AddEnumConstant_Entity.class);
5821 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5822 index.put((AddEnumConstant_Entity)
5823 newStore.getModel().convertRawObject(raw));
5827 void readRawObjects(RawStore store,
5828 boolean expectEvolved,
5829 boolean expectUpdated)
5830 throws DatabaseException {
5832 RawObject obj = readRaw
5833 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5834 RawType enumType = store.getModel().getRawType(NAME2);
5835 if (expectUpdated) {
5836 checkRawFields(obj, "key", 99,
5837 "e1", new RawObject(enumType, "A"),
5838 "e2", new RawObject(enumType, "B"),
5839 "e3", new RawObject(enumType, "C"));
5841 checkRawFields(obj, "key", 99,
5842 "e1", new RawObject(enumType, "A"),
5843 "e2", new RawObject(enumType, "B"));
5848 enum InsertEnumConstant_Enum {
5853 static class InsertEnumConstant_KeyClass
5854 implements Comparable<InsertEnumConstant_KeyClass > {
5857 InsertEnumConstant_Enum key;
5859 private InsertEnumConstant_KeyClass() {}
5861 InsertEnumConstant_KeyClass(InsertEnumConstant_Enum key) {
5865 public int compareTo(InsertEnumConstant_KeyClass o) {
5866 /* Use the natural order, in spite of insertions. */
5867 return key.compareTo(o.key);
5872 static class InsertEnumConstant_Entity
5873 extends EvolveCase {
5875 private static final String NAME =
5876 InsertEnumConstant_Entity.class.getName();
5877 private static final String NAME2 =
5878 InsertEnumConstant_Enum.class.getName();
5879 private static final String NAME3 =
5880 InsertEnumConstant_KeyClass.class.getName();
5885 @SecondaryKey(relate=MANY_TO_ONE)
5886 InsertEnumConstant_KeyClass secKey;
5888 InsertEnumConstant_Enum e1;
5889 InsertEnumConstant_Enum e2;
5890 InsertEnumConstant_Enum e3 = InsertEnumConstant_Enum.X;
5891 InsertEnumConstant_Enum e4 = InsertEnumConstant_Enum.Y;
5892 InsertEnumConstant_Enum e5 = InsertEnumConstant_Enum.Z;
5895 void checkEvolvedModel(EntityModel model,
5897 boolean oldTypesExist) {
5898 checkEntity(true, model, env, NAME, 1, null);
5899 if (oldTypesExist) {
5900 checkVersions(model, NAME, 1, NAME, 0);
5901 checkVersions(model, NAME2, 0, NAME2, 0);
5902 checkVersions(model, NAME3, 0, NAME3, 0);
5904 checkVersions(model, NAME, 1);
5905 checkVersions(model, NAME2, 0);
5906 checkVersions(model, NAME3, 0);
5911 void readObjects(EntityStore store, boolean doUpdate)
5912 throws DatabaseException {
5914 PrimaryIndex<Integer, InsertEnumConstant_Entity>
5915 index = store.getPrimaryIndex
5917 InsertEnumConstant_Entity.class);
5918 InsertEnumConstant_Entity obj = index.get(99);
5919 TestCase.assertNotNull(obj);
5920 TestCase.assertEquals(99, obj.key);
5922 TestCase.assertSame(InsertEnumConstant_Enum.X, obj.secKey.key);
5924 TestCase.assertSame(InsertEnumConstant_Enum.A, obj.secKey.key);
5926 TestCase.assertSame(InsertEnumConstant_Enum.A, obj.e1);
5927 TestCase.assertSame(InsertEnumConstant_Enum.B, obj.e2);
5928 TestCase.assertSame(InsertEnumConstant_Enum.X, obj.e3);
5929 TestCase.assertSame(InsertEnumConstant_Enum.Y, obj.e4);
5930 TestCase.assertSame(InsertEnumConstant_Enum.Z, obj.e5);
5934 new InsertEnumConstant_KeyClass(InsertEnumConstant_Enum.X);
5941 void copyRawObjects(RawStore rawStore, EntityStore newStore)
5942 throws DatabaseException {
5944 PrimaryIndex<Integer, InsertEnumConstant_Entity>
5945 index = newStore.getPrimaryIndex
5947 InsertEnumConstant_Entity.class);
5948 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5949 index.put((InsertEnumConstant_Entity)
5950 newStore.getModel().convertRawObject(raw));
5954 void readRawObjects(RawStore store,
5955 boolean expectEvolved,
5956 boolean expectUpdated)
5957 throws DatabaseException {
5959 RawObject obj = readRaw
5960 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5961 RawType enumType = store.getModel().getRawType(NAME2);
5963 Map<String, Object> secKeyFields = new HashMap<String, Object>();
5964 RawType secKeyType = store.getModel().getRawType(NAME3);
5965 RawObject secKeyObject =
5966 new RawObject(secKeyType, secKeyFields, null /*superObject*/);
5968 if (expectUpdated) {
5969 secKeyFields.put("key", new RawObject(enumType, "X"));
5970 checkRawFields(obj, "key", 99,
5971 "secKey", secKeyObject,
5972 "e1", new RawObject(enumType, "A"),
5973 "e2", new RawObject(enumType, "B"),
5974 "e3", new RawObject(enumType, "X"),
5975 "e4", new RawObject(enumType, "Y"),
5976 "e5", new RawObject(enumType, "Z"));
5978 secKeyFields.put("key", new RawObject(enumType, "A"));
5979 checkRawFields(obj, "key", 99,
5980 "secKey", secKeyObject,
5981 "e1", new RawObject(enumType, "A"),
5982 "e2", new RawObject(enumType, "B"));
5987 enum DeleteEnumConstant_Enum {
5992 * Don't allow deleting (or renaming, which appears as a deletion) enum
5993 * values without mutations.
5996 static class DeleteEnumConstant_NoMutation
5997 extends EvolveCase {
6002 DeleteEnumConstant_Enum e1;
6003 DeleteEnumConstant_Enum e2;
6004 DeleteEnumConstant_Enum e3;
6007 public String getStoreOpenException() {
6008 return "com.sleepycat.persist.evolve.IncompatibleClassException: Incompatible enum type changed detected when evolving class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 Error: Enum values may not be removed: [B]";
6013 * With a Deleter, deleted enum values are null. Note that version is not
6016 /* Disabled until support for enum deletion is added.
6018 static class DeleteEnumConstant_WithDeleter
6019 extends EvolveCase {
6021 private static final String NAME =
6022 DeleteEnumConstant_WithDeleter.class.getName();
6023 private static final String NAME2 =
6024 DeleteEnumConstant_Enum.class.getName();
6029 DeleteEnumConstant_Enum e1;
6030 DeleteEnumConstant_Enum e2;
6031 DeleteEnumConstant_Enum e3;
6034 void checkEvolvedModel(EntityModel model,
6036 boolean oldTypesExist) {
6037 checkEntity(true, model, env, NAME, 0, null);
6038 checkVersions(model, NAME, 0);
6039 if (oldTypesExist) {
6040 checkVersions(model, NAME2, 0, NAME2, 0);
6042 checkVersions(model, NAME2, 0);
6047 void readObjects(EntityStore store, boolean doUpdate)
6048 throws DatabaseException {
6050 PrimaryIndex<Integer, DeleteEnumConstant_WithDeleter>
6051 index = store.getPrimaryIndex
6053 DeleteEnumConstant_WithDeleter.class);
6054 DeleteEnumConstant_WithDeleter obj = index.get(99);
6055 TestCase.assertNotNull(obj);
6056 TestCase.assertEquals(99, obj.key);
6057 TestCase.assertSame(DeleteEnumConstant_Enum.A, obj.e1);
6058 TestCase.assertSame(null, obj.e2);
6059 TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e3);
6067 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6068 throws DatabaseException {
6070 PrimaryIndex<Integer, DeleteEnumConstant_WithDeleter>
6071 index = newStore.getPrimaryIndex
6073 DeleteEnumConstant_WithDeleter.class);
6074 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
6075 index.put((DeleteEnumConstant_WithDeleter)
6076 newStore.getModel().convertRawObject(raw));
6080 void readRawObjects(RawStore store,
6081 boolean expectEvolved,
6082 boolean expectUpdated)
6083 throws DatabaseException {
6085 RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
6086 RawType enumType = store.getModel().getRawType(NAME2);
6087 if (expectUpdated) {
6088 checkRawFields(obj, "key", 99,
6089 "e1", new RawObject(enumType, "A"),
6091 "e3", new RawObject(enumType, "C"));
6093 checkRawFields(obj, "key", 99,
6094 "e1", new RawObject(enumType, "A"),
6095 "e2", new RawObject(enumType, "B"),
6096 "e3", new RawObject(enumType, "C"));
6103 * A field converter can assign deleted enum values. Version must be
6104 * bumped when a converter is added.
6106 /* Disabled until support for enum deletion is added.
6108 static class DeleteEnumConstant_WithConverter
6109 extends EvolveCase {
6111 private static final String NAME =
6112 DeleteEnumConstant_WithConverter.class.getName();
6113 private static final String NAME2 =
6114 DeleteEnumConstant_Enum.class.getName();
6119 DeleteEnumConstant_Enum e1;
6120 DeleteEnumConstant_Enum e2;
6121 DeleteEnumConstant_Enum e3;
6124 Mutations getMutations() {
6125 Mutations m = new Mutations();
6126 Conversion c = new MyConversion();
6127 m.addConverter(new Converter(NAME, 0, "e1", c));
6128 m.addConverter(new Converter(NAME, 0, "e2", c));
6129 m.addConverter(new Converter(NAME, 0, "e3", c));
6133 @SuppressWarnings("serial")
6134 static class MyConversion implements Conversion {
6136 transient RawType newType;
6138 public void initialize(EntityModel model) {
6139 newType = model.getRawType(NAME2);
6140 TestCase.assertNotNull(newType);
6143 public Object convert(Object fromValue) {
6144 TestCase.assertNotNull(newType);
6145 RawObject obj = (RawObject) fromValue;
6146 String val = obj.getEnum();
6147 TestCase.assertNotNull(val);
6148 if ("B".equals(val)) {
6151 return new RawObject(newType, val);
6155 public boolean equals(Object other) {
6156 return other instanceof MyConversion;
6161 void checkEvolvedModel(EntityModel model,
6163 boolean oldTypesExist) {
6164 checkEntity(true, model, env, NAME, 1, null);
6165 if (oldTypesExist) {
6166 checkVersions(model, NAME, 1, NAME, 0);
6167 checkVersions(model, NAME2, 0, NAME2, 0);
6169 checkVersions(model, NAME, 1);
6170 checkVersions(model, NAME2, 0);
6175 void readObjects(EntityStore store, boolean doUpdate)
6176 throws DatabaseException {
6178 PrimaryIndex<Integer, DeleteEnumConstant_WithConverter>
6179 index = store.getPrimaryIndex
6181 DeleteEnumConstant_WithConverter.class);
6182 DeleteEnumConstant_WithConverter obj = index.get(99);
6183 TestCase.assertNotNull(obj);
6184 TestCase.assertEquals(99, obj.key);
6185 TestCase.assertSame(DeleteEnumConstant_Enum.A, obj.e1);
6186 TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e2);
6187 TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e3);
6195 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6196 throws DatabaseException {
6198 PrimaryIndex<Integer, DeleteEnumConstant_WithConverter>
6199 index = newStore.getPrimaryIndex
6201 DeleteEnumConstant_WithConverter.class);
6202 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
6203 index.put((DeleteEnumConstant_WithConverter)
6204 newStore.getModel().convertRawObject(raw));
6208 void readRawObjects(RawStore store,
6209 boolean expectEvolved,
6210 boolean expectUpdated)
6211 throws DatabaseException {
6213 RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1 : 0,
6215 RawType enumType = store.getModel().getRawType(NAME2);
6216 if (expectEvolved) {
6217 checkRawFields(obj, "key", 99,
6218 "e1", new RawObject(enumType, "A"),
6219 "e2", new RawObject(enumType, "C"),
6220 "e3", new RawObject(enumType, "C"));
6222 checkRawFields(obj, "key", 99,
6223 "e1", new RawObject(enumType, "A"),
6224 "e2", new RawObject(enumType, "B"),
6225 "e3", new RawObject(enumType, "C"));
6232 static class DisallowChangeKeyRelate
6233 extends EvolveCase {
6235 private static final String NAME =
6236 DisallowChangeKeyRelate.class.getName();
6241 @SecondaryKey(relate=MANY_TO_ONE)
6245 public String getStoreOpenException() {
6246 return "com.sleepycat.persist.evolve.IncompatibleClassException: Change detected in the relate attribute (Relationship) of a secondary key when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowChangeKeyRelate version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowChangeKeyRelate version: 0 Error: Old key: skey relate: ONE_TO_ONE new key: skey relate: MANY_TO_ONE";
6251 static class AllowChangeKeyMetadata
6252 extends EvolveCase {
6254 private static final String NAME =
6255 AllowChangeKeyMetadata.class.getName();
6261 * Combined fields from version 0 and 1:
6262 * addAnnotation = 88;
6264 * dropAnnotation = 66;
6266 * renamedField = 44; // was toBeRenamedField
6273 @SecondaryKey(relate=ONE_TO_ONE)
6278 @SecondaryKey(relate=ONE_TO_ONE)
6281 @SecondaryKey(relate=ONE_TO_ONE)
6287 Mutations getMutations() {
6288 Mutations m = new Mutations();
6289 m.addDeleter(new Deleter(NAME, 0, "dropField"));
6290 m.addRenamer(new Renamer(NAME, 0, "toBeRenamedField",
6296 void checkEvolvedModel(EntityModel model,
6298 boolean oldTypesExist) {
6299 checkEntity(true, model, env, NAME, 1, null);
6300 if (oldTypesExist) {
6301 checkVersions(model, NAME, 1, NAME, 0);
6303 checkVersions(model, NAME, 1);
6308 void readObjects(EntityStore store, boolean doUpdate)
6309 throws DatabaseException {
6311 PrimaryIndex<Integer, AllowChangeKeyMetadata>
6312 index = store.getPrimaryIndex
6314 AllowChangeKeyMetadata.class);
6315 AllowChangeKeyMetadata obj = index.get(99);
6318 if (newMetadataWritten) {
6319 checkValues(store.getSecondaryIndex
6320 (index, Integer.class, "addAnnotation").get(88));
6321 checkValues(store.getSecondaryIndex
6322 (index, Integer.class, "renamedField").get(44));
6324 checkValues(store.getSecondaryIndex
6325 (index, Integer.class, "addField").get(55));
6327 TestCase.assertNull(store.getSecondaryIndex
6328 (index, Integer.class, "addField").get(55));
6335 checkValues(store.getSecondaryIndex
6336 (index, Integer.class, "addAnnotation").get(88));
6337 checkValues(store.getSecondaryIndex
6338 (index, Integer.class, "addField").get(55));
6344 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6345 throws DatabaseException {
6347 PrimaryIndex<Integer, AllowChangeKeyMetadata>
6348 index = newStore.getPrimaryIndex
6350 AllowChangeKeyMetadata.class);
6351 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
6352 index.put((AllowChangeKeyMetadata)
6353 newStore.getModel().convertRawObject(raw));
6356 private void checkValues(AllowChangeKeyMetadata obj) {
6357 TestCase.assertNotNull(obj);
6358 TestCase.assertEquals(99, obj.key);
6359 TestCase.assertEquals(88, obj.addAnnotation);
6360 TestCase.assertEquals(66, obj.dropAnnotation);
6361 TestCase.assertEquals(44, obj.renamedField);
6362 TestCase.assertEquals(33, obj.aa);
6363 TestCase.assertEquals(22, obj.ff);
6365 TestCase.assertEquals(Integer.valueOf(55), obj.addField);
6367 TestCase.assertNull(obj.addField);
6372 void readRawObjects(RawStore store,
6373 boolean expectEvolved,
6374 boolean expectUpdated)
6375 throws DatabaseException {
6377 RawObject obj = readRaw
6378 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
6379 if (expectUpdated) {
6380 checkRawFields(obj, "key", 99,
6381 "addAnnotation", 88,
6382 "dropAnnotation", 66,
6387 } else if (expectEvolved) {
6388 checkRawFields(obj, "key", 99,
6389 "addAnnotation", 88,
6390 "dropAnnotation", 66,
6395 checkRawFields(obj, "key", 99,
6396 "addAnnotation", 88,
6398 "dropAnnotation", 66,
6399 "toBeRenamedField", 44,
6403 Environment env = store.getEnvironment();
6404 assertDbExists(expectEvolved, env, NAME, "addAnnotation");
6405 assertDbExists(expectEvolved, env, NAME, "addField");
6406 assertDbExists(expectEvolved, env, NAME, "renamedField");
6407 assertDbExists(!expectEvolved, env, NAME, "toBeRenamedField");
6408 assertDbExists(!expectEvolved, env, NAME, "dropField");
6409 assertDbExists(!expectEvolved, env, NAME, "dropAnnotation");
6414 * Same test as AllowChangeKeyMetadata but with the secondary keys in an
6415 * entity subclass. [#16253]
6417 @Persistent(version=1)
6418 static class AllowChangeKeyMetadataInSubclass
6419 extends AllowChangeKeyMetadataEntity {
6421 private static final String NAME =
6422 AllowChangeKeyMetadataInSubclass.class.getName();
6423 private static final String NAME2 =
6424 AllowChangeKeyMetadataEntity.class.getName();
6427 * Combined fields from version 0 and 1:
6428 * addAnnotation = 88;
6430 * dropAnnotation = 66;
6432 * renamedField = 44; // was toBeRenamedField
6439 @SecondaryKey(relate=ONE_TO_ONE)
6444 @SecondaryKey(relate=ONE_TO_ONE)
6447 @SecondaryKey(relate=ONE_TO_ONE)
6453 void configure(EntityModel model, StoreConfig config) {
6454 model.registerClass(AllowChangeKeyMetadataInSubclass.class);
6458 Mutations getMutations() {
6459 Mutations m = new Mutations();
6460 m.addDeleter(new Deleter(NAME, 0, "dropField"));
6461 m.addRenamer(new Renamer(NAME, 0, "toBeRenamedField",
6467 void checkEvolvedModel(EntityModel model,
6469 boolean oldTypesExist) {
6470 checkNonEntity(true, model, env, NAME, 1);
6471 checkEntity(true, model, env, NAME2, 0, null);
6472 if (oldTypesExist) {
6473 checkVersions(model, NAME, 1, NAME, 0);
6474 checkVersions(model, NAME2, 0);
6476 checkVersions(model, NAME, 1);
6477 checkVersions(model, NAME2, 0);
6482 void readObjects(EntityStore store, boolean doUpdate)
6483 throws DatabaseException {
6485 PrimaryIndex<Integer, AllowChangeKeyMetadataEntity>
6486 index = store.getPrimaryIndex
6488 AllowChangeKeyMetadataEntity.class);
6489 AllowChangeKeyMetadataEntity obj = index.get(99);
6492 if (newMetadataWritten) {
6493 checkValues(store.getSecondaryIndex
6494 (index, Integer.class, "addAnnotation").get(88));
6495 checkValues(store.getSecondaryIndex
6496 (index, Integer.class, "renamedField").get(44));
6498 checkValues(store.getSecondaryIndex
6499 (index, Integer.class, "addField").get(55));
6501 TestCase.assertNull(store.getSecondaryIndex
6502 (index, Integer.class, "addField").get(55));
6506 ((AllowChangeKeyMetadataInSubclass) obj).addField = 55;
6509 checkValues(store.getSecondaryIndex
6510 (index, Integer.class, "addAnnotation").get(88));
6511 checkValues(store.getSecondaryIndex
6512 (index, Integer.class, "addField").get(55));
6518 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6519 throws DatabaseException {
6521 PrimaryIndex<Integer, AllowChangeKeyMetadataEntity>
6522 index = newStore.getPrimaryIndex
6524 AllowChangeKeyMetadataEntity.class);
6525 RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
6526 index.put((AllowChangeKeyMetadataInSubclass)
6527 newStore.getModel().convertRawObject(raw));
6530 private void checkValues(AllowChangeKeyMetadataEntity objParam) {
6531 AllowChangeKeyMetadataInSubclass obj =
6532 (AllowChangeKeyMetadataInSubclass) objParam;
6533 TestCase.assertNotNull(obj);
6534 TestCase.assertEquals(99, obj.key);
6535 TestCase.assertEquals(88, obj.addAnnotation);
6536 TestCase.assertEquals(66, obj.dropAnnotation);
6537 TestCase.assertEquals(44, obj.renamedField);
6538 TestCase.assertEquals(33, obj.aa);
6539 TestCase.assertEquals(22, obj.ff);
6541 TestCase.assertEquals(Integer.valueOf(55), obj.addField);
6543 TestCase.assertNull(obj.addField);
6548 void readRawObjects(RawStore store,
6549 boolean expectEvolved,
6550 boolean expectUpdated)
6551 throws DatabaseException {
6553 RawObject obj = readRaw
6554 (store, NAME2, 99, NAME, expectEvolved ? 1 : 0,
6555 NAME2, 0, CASECLS, 0);
6556 checkRawFields(obj.getSuper(), "key", 99);
6557 if (expectUpdated) {
6559 "addAnnotation", 88,
6560 "dropAnnotation", 66,
6565 } else if (expectEvolved) {
6567 "addAnnotation", 88,
6568 "dropAnnotation", 66,
6574 "addAnnotation", 88,
6576 "dropAnnotation", 66,
6577 "toBeRenamedField", 44,
6581 Environment env = store.getEnvironment();
6582 assertDbExists(expectEvolved, env, NAME2, "addAnnotation");
6583 assertDbExists(expectEvolved, env, NAME2, "addField");
6584 assertDbExists(expectEvolved, env, NAME2, "renamedField");
6585 assertDbExists(!expectEvolved, env, NAME2, "toBeRenamedField");
6586 assertDbExists(!expectEvolved, env, NAME2, "dropField");
6587 assertDbExists(!expectEvolved, env, NAME2, "dropAnnotation");
6592 static class AllowChangeKeyMetadataEntity
6593 extends EvolveCase {
6600 * Special case of adding secondaries that caused
6601 * IndexOutOfBoundsException. [#15524]
6604 static class AllowAddSecondary
6605 extends EvolveCase {
6607 private static final String NAME =
6608 AllowAddSecondary.class.getName();
6613 @SecondaryKey(relate=ONE_TO_ONE)
6616 @SecondaryKey(relate=ONE_TO_ONE)
6620 void checkEvolvedModel(EntityModel model,
6622 boolean oldTypesExist) {
6623 checkEntity(true, model, env, NAME, 1, null);
6624 if (oldTypesExist) {
6625 checkVersions(model, NAME, 1, NAME, 0);
6627 checkVersions(model, NAME, 1);
6632 void readObjects(EntityStore store, boolean doUpdate)
6633 throws DatabaseException {
6635 PrimaryIndex<Long, AllowAddSecondary>
6636 index = store.getPrimaryIndex
6638 AllowAddSecondary.class);
6639 AllowAddSecondary obj = index.get(99L);
6642 if (newMetadataWritten) {
6643 checkValues(store.getSecondaryIndex
6644 (index, Integer.class, "a").get(1));
6646 checkValues(store.getSecondaryIndex
6647 (index, Integer.class, "b").get(3));
6648 TestCase.assertNull(store.getSecondaryIndex
6649 (index, Integer.class, "b").get(2));
6651 checkValues(store.getSecondaryIndex
6652 (index, Integer.class, "b").get(2));
6653 TestCase.assertNull(store.getSecondaryIndex
6654 (index, Integer.class, "b").get(3));
6661 checkValues(store.getSecondaryIndex
6662 (index, Integer.class, "a").get(1));
6663 checkValues(store.getSecondaryIndex
6664 (index, Integer.class, "b").get(3));
6670 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6671 throws DatabaseException {
6673 PrimaryIndex<Long, AllowAddSecondary>
6674 index = newStore.getPrimaryIndex
6676 AllowAddSecondary.class);
6677 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99L);
6678 index.put((AllowAddSecondary)
6679 newStore.getModel().convertRawObject(raw));
6682 private void checkValues(AllowAddSecondary obj) {
6683 TestCase.assertNotNull(obj);
6684 TestCase.assertEquals(99L, obj.key);
6685 TestCase.assertEquals(1, obj.a);
6687 TestCase.assertEquals(3, obj.b);
6689 TestCase.assertEquals(2, obj.b);
6694 void readRawObjects(RawStore store,
6695 boolean expectEvolved,
6696 boolean expectUpdated)
6697 throws DatabaseException {
6699 RawObject obj = readRaw
6700 (store, 99L, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
6701 if (expectUpdated) {
6702 checkRawFields(obj, "key", 99L,
6706 checkRawFields(obj, "key", 99L,
6710 Environment env = store.getEnvironment();
6711 assertDbExists(expectEvolved, env, NAME, "a");
6712 assertDbExists(expectEvolved, env, NAME, "b");
6717 static class FieldAddAndConvert
6718 extends EvolveCase {
6720 private static final String NAME =
6721 FieldAddAndConvert.class.getName();
6726 private final String f0 = "0"; // new field
6727 private final String f1 = "1"; // converted field
6728 private final String f2 = "2"; // new field
6729 private final String f3 = "3"; // converted field
6730 private final String f4 = "4"; // new field
6733 Mutations getMutations() {
6734 Mutations m = new Mutations();
6735 m.addConverter(new Converter(NAME, 0, "f1", new IntToString()));
6736 m.addConverter(new Converter(NAME, 0, "f3", new IntToString()));
6740 @SuppressWarnings("serial")
6741 private static class IntToString implements Conversion {
6743 public void initialize(EntityModel model) {
6746 public Object convert(Object fromValue) {
6747 return fromValue.toString();
6751 public boolean equals(Object other) {
6752 return other instanceof IntToString;
6757 void checkEvolvedModel(EntityModel model,
6759 boolean oldTypesExist) {
6760 checkEntity(true, model, env, NAME, 1, null);
6761 if (oldTypesExist) {
6762 checkVersions(model, NAME, 1, NAME, 0);
6764 checkVersions(model, NAME, 1);
6769 void readObjects(EntityStore store, boolean doUpdate)
6770 throws DatabaseException {
6772 PrimaryIndex<Integer, FieldAddAndConvert>
6773 index = store.getPrimaryIndex
6775 FieldAddAndConvert.class);
6776 FieldAddAndConvert obj = index.get(99);
6777 TestCase.assertNotNull(obj);
6778 TestCase.assertEquals(99, obj.key);
6779 TestCase.assertEquals("0", obj.f0);
6780 TestCase.assertEquals("1", obj.f1);
6781 TestCase.assertEquals("2", obj.f2);
6782 TestCase.assertEquals("3", obj.f3);
6783 TestCase.assertEquals("4", obj.f4);
6791 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6792 throws DatabaseException {
6794 PrimaryIndex<Integer, FieldAddAndConvert>
6795 index = newStore.getPrimaryIndex
6797 FieldAddAndConvert.class);
6798 RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
6799 index.put((FieldAddAndConvert)
6800 newStore.getModel().convertRawObject(raw));
6804 void readRawObjects(RawStore store,
6805 boolean expectEvolved,
6806 boolean expectUpdated)
6807 throws DatabaseException {
6809 RawObject obj = readRaw
6810 (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
6811 if (expectUpdated) {
6819 } else if (expectEvolved) {
6834 * [18961]Rename secKey2, so the order of secondary keys' names is changed
6835 * from: secKey->seckey2->secKey3 to new_seckey2->secKey->secKey3.
6838 static class RenameSecFieldDestroyOrder_1 extends EvolveCase{
6840 private static final String NAME =
6841 RenameSecFieldDestroyOrder_1.class.getName();
6846 @SecondaryKey(relate=MANY_TO_ONE)
6849 /* Rename secKey2 to new_secKey2. */
6850 @SecondaryKey(relate=MANY_TO_ONE)
6853 @SecondaryKey(relate=MANY_TO_ONE)
6857 Mutations getMutations() {
6858 Mutations m = new Mutations();
6859 m.addRenamer(new Renamer(NAME, 0, "secKey2", "new_secKey2"));
6864 void checkEvolvedModel(EntityModel model,
6866 boolean oldTypesExist) {
6867 checkEntity(true, model, env, NAME, 1, null);
6868 if (oldTypesExist) {
6869 checkVersions(model, NAME, 1, NAME, 0);
6871 checkVersions(model, NAME, 1);
6876 void readObjects(EntityStore store, boolean doUpdate)
6877 throws DatabaseException {
6879 PrimaryIndex<Integer, RenameSecFieldDestroyOrder_1>
6880 index = store.getPrimaryIndex
6881 (Integer.class, RenameSecFieldDestroyOrder_1.class);
6882 RenameSecFieldDestroyOrder_1 obj = index.get(1);
6884 checkSecondaries(store, index);
6888 checkSecondaries(store, index);
6893 void copyRawObjects(RawStore rawStore, EntityStore newStore)
6894 throws DatabaseException {
6896 PrimaryIndex<Integer, RenameSecFieldDestroyOrder_1>
6897 index = newStore.getPrimaryIndex
6898 (Integer.class, RenameSecFieldDestroyOrder_1.class);
6899 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
6900 index.put((RenameSecFieldDestroyOrder_1)
6901 newStore.getModel().convertRawObject(raw));
6904 private void checkSecondaries(EntityStore store,
6905 PrimaryIndex<Integer,
6906 RenameSecFieldDestroyOrder_1>
6908 throws DatabaseException {
6910 if (!newMetadataWritten) {
6913 checkValues(store.getSecondaryIndex
6914 (index, String.class, "secKey").get("aa"));
6915 checkValues(store.getSecondaryIndex
6916 (index, Integer.class, "new_secKey2").get(2));
6917 checkValues(store.getSecondaryIndex
6918 (index, String.class, "secKey3").get("bb"));
6921 private void checkValues(RenameSecFieldDestroyOrder_1 obj) {
6922 TestCase.assertNotNull(obj);
6923 TestCase.assertEquals(obj.key, 1);
6924 TestCase.assertEquals(obj.secKey, "aa");
6925 TestCase.assertEquals(obj.new_secKey2, 2);
6926 TestCase.assertEquals(obj.secKey3, "bb");
6930 void readRawObjects(RawStore store,
6931 boolean expectEvolved,
6932 boolean expectUpdated)
6933 throws DatabaseException {
6936 if (expectEvolved) {
6937 obj = readRaw(store, 1, NAME, 1, CASECLS, 0);
6938 checkRawFields(obj, "key", 1,
6943 obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
6944 checkRawFields(obj, "key", 1,
6949 Environment env = store.getEnvironment();
6951 assertDbExists(expectEvolved, env, NAME, "new_secKey2");
6952 assertDbExists(!expectEvolved, env, NAME, "secKey2");
6957 * [18961]Rename secKey2 and secKey3, so the order of secondary keys' names
6958 * is changed from : secKey->seckey2->secKey3 to new_seckey2->new_secKey3->
6962 static class RenameSecFieldDestroyOrder_2 extends EvolveCase{
6964 private static final String NAME =
6965 RenameSecFieldDestroyOrder_2.class.getName();
6970 @SecondaryKey(relate=MANY_TO_ONE)
6973 /* Rename secKey2 to new_secKey2. */
6974 @SecondaryKey(relate=MANY_TO_ONE)
6977 /* Rename secKey3 to new_secKey3. */
6978 @SecondaryKey(relate=MANY_TO_ONE)
6982 Mutations getMutations() {
6983 Mutations m = new Mutations();
6984 m.addRenamer(new Renamer(NAME, 0, "secKey2", "new_secKey2"));
6985 m.addRenamer(new Renamer(NAME, 0, "secKey3", "new_secKey3"));
6990 void checkEvolvedModel(EntityModel model,
6992 boolean oldTypesExist) {
6993 checkEntity(true, model, env, NAME, 1, null);
6994 if (oldTypesExist) {
6995 checkVersions(model, NAME, 1, NAME, 0);
6997 checkVersions(model, NAME, 1);
7002 void readObjects(EntityStore store, boolean doUpdate)
7003 throws DatabaseException {
7005 PrimaryIndex<Integer, RenameSecFieldDestroyOrder_2>
7006 index = store.getPrimaryIndex
7007 (Integer.class, RenameSecFieldDestroyOrder_2.class);
7008 RenameSecFieldDestroyOrder_2 obj = index.get(1);
7010 checkSecondaries(store, index);
7014 checkSecondaries(store, index);
7019 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7020 throws DatabaseException {
7022 PrimaryIndex<Integer, RenameSecFieldDestroyOrder_2>
7023 index = newStore.getPrimaryIndex
7024 (Integer.class, RenameSecFieldDestroyOrder_2.class);
7025 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7026 index.put((RenameSecFieldDestroyOrder_2)
7027 newStore.getModel().convertRawObject(raw));
7030 private void checkSecondaries(EntityStore store,
7031 PrimaryIndex<Integer,
7032 RenameSecFieldDestroyOrder_2>
7034 throws DatabaseException {
7036 if (!newMetadataWritten) {
7039 checkValues(store.getSecondaryIndex
7040 (index, String.class, "secKey").get("aa"));
7041 checkValues(store.getSecondaryIndex
7042 (index, Integer.class, "new_secKey2").get(2));
7043 checkValues(store.getSecondaryIndex
7044 (index, String.class, "new_secKey3").get("bb"));
7047 private void checkValues(RenameSecFieldDestroyOrder_2 obj) {
7048 TestCase.assertNotNull(obj);
7049 TestCase.assertEquals(obj.key, 1);
7050 TestCase.assertEquals(obj.secKey, "aa");
7051 TestCase.assertEquals(obj.new_secKey2, 2);
7052 TestCase.assertEquals(obj.new_secKey3, "bb");
7056 void readRawObjects(RawStore store,
7057 boolean expectEvolved,
7058 boolean expectUpdated)
7059 throws DatabaseException {
7062 if (expectEvolved) {
7063 obj = readRaw(store, 1, NAME, 1, CASECLS, 0);
7064 checkRawFields(obj, "key", 1,
7067 "new_secKey3", "bb");
7069 obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7070 checkRawFields(obj, "key", 1,
7075 Environment env = store.getEnvironment();
7077 assertDbExists(expectEvolved, env, NAME, "new_secKey2");
7078 assertDbExists(!expectEvolved, env, NAME, "secKey2");
7079 assertDbExists(expectEvolved, env, NAME, "new_secKey3");
7080 assertDbExists(!expectEvolved, env, NAME, "secKey3");
7085 * [18961]Rename secKey2 and secKey3, so the order of secondary keys' names
7086 * is changed from : secKey->seckey2->secKey3 to new_seckey3->pnew_secKey2
7090 static class RenameSecFieldDestroyOrder_3 extends EvolveCase{
7092 private static final String NAME =
7093 RenameSecFieldDestroyOrder_3.class.getName();
7098 @SecondaryKey(relate=MANY_TO_ONE)
7101 /* Rename secKey2 to pnew_secKey2. */
7102 @SecondaryKey(relate=MANY_TO_ONE)
7105 /* Rename secKey3 to new_secKey3. */
7106 @SecondaryKey(relate=MANY_TO_ONE)
7110 Mutations getMutations() {
7111 Mutations m = new Mutations();
7112 m.addRenamer(new Renamer(NAME, 0, "secKey2", "pnew_secKey2"));
7113 m.addRenamer(new Renamer(NAME, 0, "secKey3", "new_secKey3"));
7118 void checkEvolvedModel(EntityModel model,
7120 boolean oldTypesExist) {
7121 checkEntity(true, model, env, NAME, 1, null);
7122 if (oldTypesExist) {
7123 checkVersions(model, NAME, 1, NAME, 0);
7125 checkVersions(model, NAME, 1);
7130 void readObjects(EntityStore store, boolean doUpdate)
7131 throws DatabaseException {
7133 PrimaryIndex<Integer, RenameSecFieldDestroyOrder_3>
7134 index = store.getPrimaryIndex
7135 (Integer.class, RenameSecFieldDestroyOrder_3.class);
7136 RenameSecFieldDestroyOrder_3 obj = index.get(1);
7138 checkSecondaries(store, index);
7142 checkSecondaries(store, index);
7147 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7148 throws DatabaseException {
7150 PrimaryIndex<Integer, RenameSecFieldDestroyOrder_3>
7151 index = newStore.getPrimaryIndex
7153 RenameSecFieldDestroyOrder_3.class);
7154 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7155 index.put((RenameSecFieldDestroyOrder_3)
7156 newStore.getModel().convertRawObject(raw));
7159 private void checkSecondaries(EntityStore store,
7160 PrimaryIndex<Integer,
7161 RenameSecFieldDestroyOrder_3>
7163 throws DatabaseException {
7165 if (!newMetadataWritten) {
7168 checkValues(store.getSecondaryIndex
7169 (index, String.class, "secKey").get("aa"));
7170 checkValues(store.getSecondaryIndex
7171 (index, Integer.class, "pnew_secKey2").get(2));
7172 checkValues(store.getSecondaryIndex
7173 (index, String.class, "new_secKey3").get("bb"));
7176 private void checkValues(RenameSecFieldDestroyOrder_3 obj) {
7177 TestCase.assertNotNull(obj);
7178 TestCase.assertEquals(obj.key, 1);
7179 TestCase.assertEquals(obj.secKey, "aa");
7180 TestCase.assertEquals(obj.pnew_secKey2, 2);
7181 TestCase.assertEquals(obj.new_secKey3, "bb");
7185 void readRawObjects(RawStore store,
7186 boolean expectEvolved,
7187 boolean expectUpdated)
7188 throws DatabaseException {
7191 if (expectEvolved) {
7192 obj = readRaw(store, 1, NAME, 1, CASECLS, 0);
7193 checkRawFields(obj, "key", 1,
7196 "new_secKey3", "bb");
7198 obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7199 checkRawFields(obj, "key", 1,
7204 Environment env = store.getEnvironment();
7206 assertDbExists(expectEvolved, env, NAME, "pnew_secKey2");
7207 assertDbExists(!expectEvolved, env, NAME, "secKey2");
7208 assertDbExists(expectEvolved, env, NAME, "new_secKey3");
7209 assertDbExists(!expectEvolved, env, NAME, "secKey3");
7214 * [#18961]Delete secKey2's SecondaryKey annotation. so the order of non
7215 * keys' names is changed from : anonKey->znonkey to anonKey->secKey2->
7219 static class DeleteSecAnnotationDestroyOrder extends EvolveCase{
7221 private static final String NAME =
7222 DeleteSecAnnotationDestroyOrder.class.getName();
7227 @SecondaryKey(relate=MANY_TO_ONE)
7230 /* Delete secKey2's SecondaryKey annotation. */
7231 //@SecondaryKey(relate=MANY_TO_ONE)
7234 @SecondaryKey(relate=MANY_TO_ONE)
7238 String xnonKey = "cc";
7241 Mutations getMutations() {
7242 Mutations m = new Mutations();
7243 m.addRenamer(new Renamer(NAME, 0, "anonKey", "znonKey"));
7248 void checkEvolvedModel(EntityModel model,
7250 boolean oldTypesExist) {
7251 checkEntity(true, model, env, NAME, 1, null);
7252 if (oldTypesExist) {
7253 checkVersions(model, NAME, 1, NAME, 0);
7255 checkVersions(model, NAME, 1);
7260 void readObjects(EntityStore store, boolean doUpdate)
7261 throws DatabaseException {
7263 PrimaryIndex<Integer, DeleteSecAnnotationDestroyOrder>
7264 index = store.getPrimaryIndex
7265 (Integer.class, DeleteSecAnnotationDestroyOrder.class);
7266 DeleteSecAnnotationDestroyOrder obj = index.get(1);
7268 checkSecondaries(store, index);
7272 checkSecondaries(store, index);
7277 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7278 throws DatabaseException {
7280 PrimaryIndex<Integer, DeleteSecAnnotationDestroyOrder>
7281 index = newStore.getPrimaryIndex
7283 DeleteSecAnnotationDestroyOrder.class);
7284 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7285 index.put((DeleteSecAnnotationDestroyOrder)
7286 newStore.getModel().convertRawObject(raw));
7289 private void checkSecondaries(EntityStore store,
7290 PrimaryIndex<Integer,
7291 DeleteSecAnnotationDestroyOrder>
7293 throws DatabaseException {
7295 if (!newMetadataWritten) {
7298 checkValues(store.getSecondaryIndex
7299 (index, String.class, "secKey").get("aa"));
7300 checkValues(store.getSecondaryIndex
7301 (index, String.class, "secKey3").get("bb"));
7304 private void checkValues(DeleteSecAnnotationDestroyOrder obj) {
7305 TestCase.assertNotNull(obj);
7306 TestCase.assertEquals(obj.key, 1);
7307 TestCase.assertEquals(obj.secKey, "aa");
7308 TestCase.assertEquals(obj.secKey2, 2);
7309 TestCase.assertEquals(obj.secKey3, "bb");
7310 TestCase.assertEquals(obj.znonKey, 3);
7311 TestCase.assertEquals(obj.xnonKey, "cc");
7315 void readRawObjects(RawStore store,
7316 boolean expectEvolved,
7317 boolean expectUpdated)
7318 throws DatabaseException {
7321 if (expectEvolved) {
7322 obj = readRaw(store, 1, NAME, 1, CASECLS, 0);
7323 checkRawFields(obj, "key", 1,
7330 obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7331 checkRawFields(obj, "key", 1,
7338 Environment env = store.getEnvironment();
7340 assertDbExists(!expectEvolved, env, NAME, "secKey2");
7345 * [#19377]Change one field of the proxy class from Map<String, String> to
7346 * Map<MyEnum, String>.
7349 static class ProxyClassFieldChanged extends EvolveCase {
7350 private static final String NAME =
7351 ProxyClassFieldChanged.class.getName();
7352 private static final String NAME2 =
7353 ProxiedClass_Proxy2.class.getName();
7358 private ProxiedClass embed;
7361 void configure(EntityModel model, StoreConfig config) {
7362 model.registerClass(ProxiedClass_Proxy2.class);
7366 Mutations getMutations() {
7367 Mutations m = new Mutations();
7368 Converter converter =
7369 new Converter(ProxiedClass_Proxy2.class.getName(), 0, "data",
7370 new MyConversion());
7371 m.addConverter(converter);
7376 void checkEvolvedModel(EntityModel model,
7378 boolean oldTypesExist) {
7379 checkEntity(true, model, env, NAME, 0, null);
7380 checkVersions(model, NAME, 0);
7381 if (oldTypesExist) {
7382 checkVersions(model, NAME2, 1, NAME2, 0);
7384 checkVersions(model, NAME2, 1);
7389 void readObjects(EntityStore store, boolean doUpdate)
7390 throws DatabaseException {
7392 PrimaryIndex<Integer, ProxyClassFieldChanged>
7393 index = store.getPrimaryIndex
7394 (Integer.class, ProxyClassFieldChanged.class);
7395 ProxyClassFieldChanged obj = index.get(1);
7396 TestCase.assertNotNull(obj);
7397 TestCase.assertEquals(1, obj.key);
7398 TestCase.assertNotNull(obj.embed);
7399 TestCase.assertEquals(2, obj.embed.data);
7406 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7407 throws DatabaseException {
7409 PrimaryIndex<Integer, ProxyClassFieldChanged>
7410 index = newStore.getPrimaryIndex
7411 (Integer.class, ProxyClassFieldChanged.class);
7412 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7413 index.put((ProxyClassFieldChanged)
7414 newStore.getModel().convertRawObject(raw));
7418 void readRawObjects(RawStore store,
7419 boolean expectEvolved,
7420 boolean expectUpdated)
7421 throws DatabaseException {
7423 RawType embedType = store.getModel().getRawType(NAME2);
7424 RawObject data = makeRawObject(store, expectEvolved);
7425 RawObject embed = new RawObject
7426 (embedType, makeValues("data", data), null);
7427 RawObject obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7428 checkRawFields(obj, "key", 1, "embed", embed);
7431 static RawObject makeRawObject(RawStore store,
7432 boolean expectEvolved) {
7433 RawType dataType = store.getModel().getRawType
7434 ("com.sleepycat.persist.impl.MapProxy$HashMapProxy");
7435 RawType dataSuperType = store.getModel().getRawType
7436 ("com.sleepycat.persist.impl.MapProxy");
7437 RawType listRawType =
7438 store.getModel().getRawType(Object[].class.getName());
7439 RawType myEnumType =
7440 store.getModel().getRawType(MyEnum.class.getName());
7441 RawObject keyRawObject = null;
7442 if (expectEvolved) {
7443 ArrayList<RawObject> dataKeyValue =
7444 new ArrayList<RawObject>();
7445 RawObject myEnumRawObject = new RawObject(myEnumType, "DATA");
7446 dataKeyValue.add(myEnumRawObject);
7447 keyRawObject = new RawObject
7448 (listRawType, dataKeyValue.toArray());
7450 ArrayList<String> dataKeyValue = new ArrayList<String>();
7451 dataKeyValue.add("data");
7452 keyRawObject = new RawObject
7453 (listRawType, dataKeyValue.toArray());
7456 ArrayList<Integer> dataValueValue = new ArrayList<Integer>();
7457 dataValueValue.add(2);
7459 RawObject valueRawObject = new RawObject
7460 (listRawType, dataValueValue.toArray());
7463 dataSuperValue = new HashMap<String, Object>();
7464 dataSuperValue.put("keys", keyRawObject);
7465 dataSuperValue.put("values", valueRawObject);
7466 RawObject dataSuperRawObject =
7467 new RawObject(dataSuperType, dataSuperValue, null);
7468 Map<String, Object> dataValue =
7469 new HashMap<String, Object>();
7470 RawObject dataRawObject = new RawObject(dataType,
7471 dataValue, dataSuperRawObject);
7472 return dataRawObject;
7475 static class MyConversion implements Conversion {
7476 private static final long serialVersionUID = 1L;
7477 private transient RawType newDataType;
7478 private transient RawType newDataSuperType;
7479 private transient RawType myEnumType;
7481 public void initialize(EntityModel model) {
7482 newDataType = model.getRawType
7483 ("com.sleepycat.persist.impl.MapProxy$HashMapProxy");
7485 model.getRawType("com.sleepycat.persist.impl.MapProxy");
7486 myEnumType = model.getRawType(MyEnum.class.getName());
7489 public Object convert(Object fromValue) {
7491 // Get field value maps for old and new objects.
7492 RawObject oldDataRawObject = (RawObject) fromValue;
7493 RawObject oldKeyRawObject = (RawObject)oldDataRawObject.
7494 getSuper().getValues().get("keys");
7495 Object[] oldDataKeyValue =
7496 (Object[])oldKeyRawObject.getElements();
7497 RawObject oldValueRawObject = (RawObject)oldDataRawObject.
7498 getSuper().getValues().get("values");
7500 ArrayList<RawObject> newDataKeyValue =
7501 new ArrayList<RawObject>();
7502 RawObject myEnumRawObject = new RawObject(myEnumType, "DATA");
7503 newDataKeyValue.add(myEnumRawObject);
7505 RawObject newKeyRawObject = new RawObject
7506 (oldKeyRawObject.getType(), newDataKeyValue.toArray());
7508 newDataSuperValue = new HashMap<String, Object>();
7509 newDataSuperValue.put("keys", newKeyRawObject);
7510 newDataSuperValue.put("values", oldValueRawObject);
7511 RawObject newDataSuperRawObject =
7512 new RawObject(newDataSuperType, newDataSuperValue, null);
7513 Map<String, Object> newDataValue =
7514 new HashMap<String, Object>();
7515 RawObject newDataRawObject =
7516 new RawObject(newDataType, newDataValue,
7517 newDataSuperRawObject);
7518 return newDataRawObject;
7522 public boolean equals(Object o) {
7523 return o instanceof MyConversion;
7528 @Persistent(proxyFor=ProxiedClass.class, version=1)
7529 static class ProxiedClass_Proxy2 implements PersistentProxy<ProxiedClass> {
7530 Map<MyEnum, Integer> data;
7532 public void initializeProxy(ProxiedClass o) {
7533 data = new HashMap<MyEnum, Integer>();
7534 data.put(MyEnum.DATA, o.data);
7537 public ProxiedClass convertProxy() {
7538 return new ProxiedClass(data.get(MyEnum.DATA));
7542 enum MyEnum { DATA };
7545 * [#19377]Change one field of the proxy class from Map<String, String> to
7546 * Map<Object, String>, and the Object component then will be assigned a
7547 * MyEnum object, which is not known for DPL when open a store.
7550 static class ProxyClassObjectFieldChanged extends EvolveCase {
7551 private static final String NAME =
7552 ProxyClassObjectFieldChanged.class.getName();
7553 private static final String NAME2 =
7554 ProxiedClass_Proxy3.class.getName();
7559 private ProxiedClass embed;
7562 void configure(EntityModel model, StoreConfig config) {
7563 model.registerClass(ProxiedClass_Proxy3.class);
7566 * Because the DPL does not know MyEnum class, we have to register
7567 * it in advance of using it.
7569 model.registerClass(MyEnum.class);
7573 Mutations getMutations() {
7574 Mutations m = new Mutations();
7575 Converter converter =
7576 new Converter(ProxiedClass_Proxy3.class.getName(), 0, "data",
7577 new ProxyClassFieldChanged.MyConversion());
7578 m.addConverter(converter);
7583 void checkEvolvedModel(EntityModel model,
7585 boolean oldTypesExist) {
7586 checkEntity(true, model, env, NAME, 0, null);
7587 checkVersions(model, NAME, 0);
7588 if (oldTypesExist) {
7589 checkVersions(model, NAME2, 1, NAME2, 0);
7591 checkVersions(model, NAME2, 1);
7596 void readObjects(EntityStore store, boolean doUpdate)
7597 throws DatabaseException {
7599 PrimaryIndex<Integer, ProxyClassObjectFieldChanged>
7600 index = store.getPrimaryIndex
7601 (Integer.class, ProxyClassObjectFieldChanged.class);
7602 ProxyClassObjectFieldChanged obj = index.get(1);
7603 TestCase.assertNotNull(obj);
7604 TestCase.assertEquals(1, obj.key);
7605 TestCase.assertNotNull(obj.embed);
7606 TestCase.assertEquals(2, obj.embed.data);
7613 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7614 throws DatabaseException {
7616 PrimaryIndex<Integer, ProxyClassObjectFieldChanged>
7617 index = newStore.getPrimaryIndex
7618 (Integer.class, ProxyClassObjectFieldChanged.class);
7619 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7620 index.put((ProxyClassObjectFieldChanged)
7621 newStore.getModel().convertRawObject(raw));
7625 void readRawObjects(RawStore store,
7626 boolean expectEvolved,
7627 boolean expectUpdated)
7628 throws DatabaseException {
7630 RawType embedType = store.getModel().getRawType(NAME2);
7632 ProxyClassFieldChanged.makeRawObject(store, expectEvolved);
7634 new RawObject(embedType, makeValues("data", data), null);
7635 RawObject obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7636 checkRawFields(obj, "key", 1, "embed", embed);
7641 @Persistent(proxyFor=ProxiedClass.class, version=1)
7642 static class ProxiedClass_Proxy3 implements PersistentProxy<ProxiedClass> {
7643 /* Changed from Map<String, String> to Map<Object, String>. */
7644 Map<Object, Integer> data;
7646 public void initializeProxy(ProxiedClass o) {
7647 data = new HashMap<Object, Integer>();
7648 data.put(MyEnum.DATA, o.data);
7651 public ProxiedClass convertProxy() {
7652 return new ProxiedClass(data.get(MyEnum.DATA));
7657 * [#19377]Change one field of the proxy class from Integer[] to
7661 static class ProxyClassArrayFieldChanged extends EvolveCase {
7662 private static final String NAME =
7663 ProxyClassArrayFieldChanged.class.getName();
7664 private static final String NAME2 =
7665 ProxiedClass_Proxy4.class.getName();
7670 private ProxiedClass embed;
7673 void configure(EntityModel model, StoreConfig config) {
7674 model.registerClass(ProxiedClass_Proxy4.class);
7678 Mutations getMutations() {
7679 Mutations m = new Mutations();
7680 Converter converter =
7681 new Converter(ProxiedClass_Proxy4.class.getName(), 0, "data",
7682 new MyConversion());
7683 m.addConverter(converter);
7688 void checkEvolvedModel(EntityModel model,
7690 boolean oldTypesExist) {
7691 checkEntity(true, model, env, NAME, 0, null);
7692 checkVersions(model, NAME, 0);
7693 if (oldTypesExist) {
7694 checkVersions(model, NAME2, 1, NAME2, 0);
7696 checkVersions(model, NAME2, 1);
7701 void readObjects(EntityStore store, boolean doUpdate)
7702 throws DatabaseException {
7704 PrimaryIndex<Integer, ProxyClassArrayFieldChanged>
7705 index = store.getPrimaryIndex
7706 (Integer.class, ProxyClassArrayFieldChanged.class);
7707 ProxyClassArrayFieldChanged obj = index.get(1);
7708 TestCase.assertNotNull(obj);
7709 TestCase.assertEquals(1, obj.key);
7710 TestCase.assertNotNull(obj.embed);
7711 TestCase.assertEquals(2, obj.embed.data);
7718 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7719 throws DatabaseException {
7721 PrimaryIndex<Integer, ProxyClassArrayFieldChanged>
7722 index = newStore.getPrimaryIndex
7723 (Integer.class, ProxyClassArrayFieldChanged.class);
7724 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7725 index.put((ProxyClassArrayFieldChanged)
7726 newStore.getModel().convertRawObject(raw));
7730 void readRawObjects(RawStore store,
7731 boolean expectEvolved,
7732 boolean expectUpdated)
7733 throws DatabaseException {
7735 RawType embedType = store.getModel().getRawType(NAME2);
7736 RawObject data = makeRawObject(store, expectEvolved);
7737 RawObject embed = new RawObject
7738 (embedType, makeValues("data", data), null);
7739 RawObject obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7740 checkRawFields(obj, "key", 1, "embed", embed);
7744 static RawObject makeRawObject(RawStore store,
7745 boolean expectEvolved) {
7746 RawType integerClassType =
7747 store.getModel().getRawType(IntegerClass.class.getName());
7748 RawObject dataRawObject = null;
7749 if (expectEvolved) {
7750 RawType dataType = store.getModel().getRawType
7751 (IntegerClass[].class.getName());
7752 Map<String, Object> integerClassValues =
7753 new HashMap<String, Object>();
7754 integerClassValues.put("data", 2);
7755 RawObject integerClassObject =
7756 new RawObject(integerClassType, integerClassValues, null);
7757 RawObject[] elements = new RawObject[1];
7758 elements[0] = integerClassObject;
7759 dataRawObject = new RawObject(dataType, elements);
7762 store.getModel().getRawType(Integer[].class.getName());
7763 Integer[] elements = new Integer[1];
7765 dataRawObject = new RawObject(dataType, elements);
7767 return dataRawObject;
7770 static class MyConversion implements Conversion {
7771 private static final long serialVersionUID = 1L;
7772 private transient RawType newDataType;
7773 private transient RawType integerClassType;
7775 public void initialize(EntityModel model) {
7776 newDataType = model.getRawType(IntegerClass[].class.getName());
7778 model.getRawType(IntegerClass.class.getName());
7781 public Object convert(Object fromValue) {
7783 // Get field value maps for old and new objects.
7784 RawObject oldDataRawObject = (RawObject) fromValue;
7785 Object[] oldElements = oldDataRawObject.getElements();
7786 Map<String, Object> integerClassValues =
7787 new HashMap<String, Object>();
7788 integerClassValues.put("data", oldElements[0]);
7789 RawObject integerClassObject =
7790 new RawObject(integerClassType, integerClassValues, null);
7791 RawObject[] newElements = new RawObject[1];
7792 newElements[0] = integerClassObject;
7793 RawObject newDataRawObject =
7794 new RawObject(newDataType, newElements);
7795 return newDataRawObject;
7799 public boolean equals(Object o) {
7800 return o instanceof MyConversion;
7805 @Persistent(proxyFor=ProxiedClass.class, version=1)
7806 static class ProxiedClass_Proxy4 implements PersistentProxy<ProxiedClass> {
7807 IntegerClass[] data;
7809 public void initializeProxy(ProxiedClass o) {
7810 data = new IntegerClass[1];
7811 data[0] = new IntegerClass(o.data);
7814 public ProxiedClass convertProxy() {
7815 return new ProxiedClass(data[0].data);
7820 static class IntegerClass {
7825 IntegerClass(int data) {
7831 * [#19377]Change one field of the proxy class from Integer[] to Object[],
7832 * and the Object component then will be assigned a IntegerClass object,
7833 * which is not known for DPL when open a store.
7836 static class ProxyClassObjectArrayFieldChanged extends EvolveCase {
7837 private static final String NAME =
7838 ProxyClassObjectArrayFieldChanged.class.getName();
7839 private static final String NAME2 =
7840 ProxiedClass_Proxy5.class.getName();
7845 private ProxiedClass embed;
7848 void configure(EntityModel model, StoreConfig config) {
7849 model.registerClass(ProxiedClass_Proxy5.class);
7850 model.registerClass(IntegerClass[].class);
7854 Mutations getMutations() {
7855 Mutations m = new Mutations();
7856 Converter converter =
7857 new Converter(ProxiedClass_Proxy5.class.getName(), 0, "data",
7858 new ProxyClassArrayFieldChanged.MyConversion());
7859 m.addConverter(converter);
7864 void checkEvolvedModel(EntityModel model,
7866 boolean oldTypesExist) {
7867 checkEntity(true, model, env, NAME, 0, null);
7868 checkVersions(model, NAME, 0);
7869 if (oldTypesExist) {
7870 checkVersions(model, NAME2, 1, NAME2, 0);
7872 checkVersions(model, NAME2, 1);
7877 void readObjects(EntityStore store, boolean doUpdate)
7878 throws DatabaseException {
7880 PrimaryIndex<Integer, ProxyClassObjectArrayFieldChanged>
7881 index = store.getPrimaryIndex
7882 (Integer.class, ProxyClassObjectArrayFieldChanged.class);
7883 ProxyClassObjectArrayFieldChanged obj = index.get(1);
7884 TestCase.assertNotNull(obj);
7885 TestCase.assertEquals(1, obj.key);
7886 TestCase.assertNotNull(obj.embed);
7887 TestCase.assertEquals(2, obj.embed.data);
7894 void copyRawObjects(RawStore rawStore, EntityStore newStore)
7895 throws DatabaseException {
7897 PrimaryIndex<Integer, ProxyClassObjectArrayFieldChanged>
7898 index = newStore.getPrimaryIndex
7899 (Integer.class, ProxyClassObjectArrayFieldChanged.class);
7900 RawObject raw = rawStore.getPrimaryIndex(NAME).get(1);
7901 index.put((ProxyClassObjectArrayFieldChanged)
7902 newStore.getModel().convertRawObject(raw));
7906 void readRawObjects(RawStore store,
7907 boolean expectEvolved,
7908 boolean expectUpdated)
7909 throws DatabaseException {
7911 RawType embedType = store.getModel().getRawType(NAME2);
7913 makeRawObject(store, expectEvolved, expectUpdated);
7914 RawObject embed = new RawObject
7915 (embedType, makeValues("data", data), null);
7916 RawObject obj = readRaw(store, 1, NAME, 0, CASECLS, 0);
7917 checkRawFields(obj, "key", 1, "embed", embed);
7921 static RawObject makeRawObject(RawStore store,
7922 boolean expectEvolved,
7923 boolean expectUpdated) {
7924 RawType integerClassType =
7925 store.getModel().getRawType(IntegerClass.class.getName());
7926 RawObject dataRawObject = null;
7927 if (expectEvolved) {
7928 RawType dataType = null;
7929 if (expectUpdated) {
7930 dataType = store.getModel().getRawType
7931 (Object[].class.getName());
7933 dataType = store.getModel().getRawType
7934 (IntegerClass[].class.getName());
7936 Map<String, Object> integerClassValues =
7937 new HashMap<String, Object>();
7938 integerClassValues.put("data", 2);
7939 RawObject integerClassObject =
7940 new RawObject(integerClassType, integerClassValues, null);
7941 RawObject[] elements = new RawObject[1];
7942 elements[0] = integerClassObject;
7943 dataRawObject = new RawObject(dataType, elements);
7946 store.getModel().getRawType(Integer[].class.getName());
7947 Integer[] elements = new Integer[1];
7949 dataRawObject = new RawObject(dataType, elements);
7951 return dataRawObject;
7955 @Persistent(proxyFor=ProxiedClass.class, version=1)
7956 static class ProxiedClass_Proxy5 implements PersistentProxy<ProxiedClass> {
7959 public void initializeProxy(ProxiedClass o) {
7960 data = new Object[1];
7961 data[0] = new IntegerClass(o.data);
7964 public ProxiedClass convertProxy() {
7965 return new ProxiedClass(((IntegerClass)data[0]).data);