KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > persist > test > EvolveClasses


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2000,2006 Oracle. All rights reserved.
5  *
6  * $Id: EvolveClasses.java,v 1.11 2006/11/15 00:17:08 mark Exp $
7  */

8 package com.sleepycat.persist.test;
9
10 import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
11 import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
12
13 import java.math.BigInteger JavaDoc;
14 import java.util.ArrayList JavaDoc;
15 import java.util.Collections JavaDoc;
16 import java.util.HashMap JavaDoc;
17 import java.util.List JavaDoc;
18 import java.util.Map JavaDoc;
19 import java.util.StringTokenizer JavaDoc;
20
21 import junit.framework.TestCase;
22
23 import com.sleepycat.je.DatabaseException;
24 import com.sleepycat.je.Environment;
25 import com.sleepycat.persist.EntityStore;
26 import com.sleepycat.persist.PrimaryIndex;
27 import com.sleepycat.persist.SecondaryIndex;
28 import com.sleepycat.persist.StoreConfig;
29 import com.sleepycat.persist.evolve.Conversion;
30 import com.sleepycat.persist.evolve.Converter;
31 import com.sleepycat.persist.evolve.Deleter;
32 import com.sleepycat.persist.evolve.EntityConverter;
33 import com.sleepycat.persist.evolve.Mutations;
34 import com.sleepycat.persist.evolve.Renamer;
35 import com.sleepycat.persist.model.Entity;
36 import com.sleepycat.persist.model.EntityModel;
37 import com.sleepycat.persist.model.KeyField;
38 import com.sleepycat.persist.model.Persistent;
39 import com.sleepycat.persist.model.PersistentProxy;
40 import com.sleepycat.persist.model.PrimaryKey;
41 import com.sleepycat.persist.model.SecondaryKey;
42 import com.sleepycat.persist.raw.RawObject;
43 import com.sleepycat.persist.raw.RawStore;
44 import com.sleepycat.persist.raw.RawType;
45
46 /**
47  * Nested classes are modified versions of classes of the same name in
48  * EvolveClasses.java.original.
49  *
50  * When adding a class, three places need to be changed:
51  * 1) Add the unmodified class to EvolveClass.java.original.
52  * 2) Add the modified class to EvolveClass.java.
53  * 3) Add the class to the list in ALL, to both EvolveClasses.java and
54  * EvolveClasses.java.original. The index in the list identifies a test
55  * case, and the class at that position identifies the old and new class
56  * to use for the test.
57  *
58  * @author Mark Hayes
59  */

60 class EvolveClasses {
61
62     private static final String JavaDoc PREFIX = EvolveClasses.class.getName() + '$';
63     private static final String JavaDoc CASECLS = EvolveCase.class.getName();
64
65     static final List JavaDoc<Class JavaDoc<? extends EvolveCase>> ALL =
66         new ArrayList JavaDoc<Class JavaDoc<? extends EvolveCase>>();
67     /* !! Order of tests here must match EvolveClasses.java.original */
68     static {
69 if (true) {
70         ALL.add(DeletedEntity1_ClassRemoved_NoMutation.class);
71         ALL.add(DeletedEntity2_ClassRemoved_WithDeleter.class);
72         ALL.add(DeletedEntity3_AnnotRemoved_NoMutation.class);
73         ALL.add(DeletedEntity4_AnnotRemoved_WithDeleter.class);
74         ALL.add(DeletedEntity5_EntityToPersist_NoMutation.class);
75         ALL.add(DeletedEntity6_EntityToPersist_WithDeleter.class);
76         ALL.add(DeletedPersist1_ClassRemoved_NoMutation.class);
77         ALL.add(DeletedPersist2_ClassRemoved_WithDeleter.class);
78         ALL.add(DeletedPersist3_AnnotRemoved_NoMutation.class);
79         ALL.add(DeletedPersist4_AnnotRemoved_WithDeleter.class);
80         ALL.add(DeletedPersist5_PersistToEntity_NoMutation.class);
81         ALL.add(DeletedPersist6_PersistToEntity_WithDeleter.class);
82         ALL.add(RenamedEntity1_NewEntityName_NoMutation.class);
83         ALL.add(RenamedEntity2_NewEntityName_WithRenamer.class);
84         ALL.add(DeleteSuperclass1_NoMutation.class);
85         ALL.add(DeleteSuperclass2_WithConverter.class);
86         ALL.add(DeleteSuperclass3_WithDeleter.class);
87         ALL.add(DeleteSuperclass4_NoFields.class);
88         ALL.add(DeleteSuperclass5_Top.class);
89         ALL.add(InsertSuperclass1_Between.class);
90         ALL.add(InsertSuperclass2_Top.class);
91         ALL.add(DisallowNonKeyField_PrimitiveToObject.class);
92         ALL.add(DisallowNonKeyField_ObjectToPrimitive.class);
93         ALL.add(DisallowNonKeyField_ObjectToSubtype.class);
94         ALL.add(DisallowNonKeyField_ObjectToUnrelatedSimple.class);
95         ALL.add(DisallowNonKeyField_ObjectToUnrelatedOther.class);
96         ALL.add(DisallowNonKeyField_byte2boolean.class);
97         ALL.add(DisallowNonKeyField_short2byte.class);
98         ALL.add(DisallowNonKeyField_int2short.class);
99         ALL.add(DisallowNonKeyField_long2int.class);
100         ALL.add(DisallowNonKeyField_float2long.class);
101         ALL.add(DisallowNonKeyField_double2float.class);
102         ALL.add(DisallowNonKeyField_Byte2byte.class);
103         ALL.add(DisallowNonKeyField_Character2char.class);
104         ALL.add(DisallowNonKeyField_Short2short.class);
105         ALL.add(DisallowNonKeyField_Integer2int.class);
106         ALL.add(DisallowNonKeyField_Long2long.class);
107         ALL.add(DisallowNonKeyField_Float2float.class);
108         ALL.add(DisallowNonKeyField_Double2double.class);
109         ALL.add(DisallowNonKeyField_float2BigInt.class);
110         ALL.add(DisallowNonKeyField_BigInt2long.class);
111         ALL.add(DisallowSecKeyField_byte2short.class);
112         ALL.add(DisallowSecKeyField_char2int.class);
113         ALL.add(DisallowSecKeyField_short2int.class);
114         ALL.add(DisallowSecKeyField_int2long.class);
115         ALL.add(DisallowSecKeyField_long2float.class);
116         ALL.add(DisallowSecKeyField_float2double.class);
117         ALL.add(DisallowSecKeyField_Byte2short2.class);
118         ALL.add(DisallowSecKeyField_Character2int.class);
119         ALL.add(DisallowSecKeyField_Short2int2.class);
120         ALL.add(DisallowSecKeyField_Integer2long.class);
121         ALL.add(DisallowSecKeyField_Long2float2.class);
122         ALL.add(DisallowSecKeyField_Float2double2.class);
123         ALL.add(DisallowSecKeyField_int2BigInt.class);
124         ALL.add(DisallowPriKeyField_byte2short.class);
125         ALL.add(DisallowPriKeyField_char2int.class);
126         ALL.add(DisallowPriKeyField_short2int.class);
127         ALL.add(DisallowPriKeyField_int2long.class);
128         ALL.add(DisallowPriKeyField_long2float.class);
129         ALL.add(DisallowPriKeyField_float2double.class);
130         ALL.add(DisallowPriKeyField_Byte2short2.class);
131         ALL.add(DisallowPriKeyField_Character2int.class);
132         ALL.add(DisallowPriKeyField_Short2int2.class);
133         ALL.add(DisallowPriKeyField_Integer2long.class);
134         ALL.add(DisallowPriKeyField_Long2float2.class);
135         ALL.add(DisallowPriKeyField_Float2double2.class);
136         ALL.add(DisallowPriKeyField_Long2BigInt.class);
137         ALL.add(DisallowCompositeKeyField_byte2short.class);
138         ALL.add(AllowPriKeyField_Byte2byte2.class);
139         ALL.add(AllowPriKeyField_byte2Byte.class);
140         ALL.add(AllowFieldTypeChanges.class);
141         ALL.add(ConvertExample1_Entity.class);
142         ALL.add(ConvertExample2_Person.class);
143         ALL.add(ConvertExample3_Person.class);
144         ALL.add(ConvertExample4_Entity.class);
145         ALL.add(ConvertExample5_Entity.class);
146         ALL.add(AllowFieldAddDelete.class);
147         ALL.add(ProxiedClass_Entity.class);
148         ALL.add(DisallowChangeProxyFor.class);
149         ALL.add(DisallowDeleteProxyFor.class);
150         ALL.add(ArrayNameChange_Entity.class);
151         ALL.add(AddEnumConstant_Entity.class);
152         ALL.add(DeleteEnumConstant_NoMutation.class);
153         ALL.add(DisallowChangeKeyRelate.class);
154         ALL.add(AllowChangeKeyMetadata.class);
155 }
156         /* Add new test classes here. */
157     }
158
159     /**
160      * Reads a raw object and checks its superclass names and versions.
161      */

162     private static RawObject readRaw(RawStore store,
163                                      Object JavaDoc key,
164                                      Object JavaDoc... classVersionPairs)
165         throws DatabaseException {
166
167         TestCase.assertNotNull(store);
168         TestCase.assertNotNull(key);
169
170         String JavaDoc entityClsName = (String JavaDoc) classVersionPairs[0];
171         PrimaryIndex<Object JavaDoc,RawObject> index =
172             store.getPrimaryIndex(entityClsName);
173         TestCase.assertNotNull(index);
174
175         RawObject obj = index.get(key);
176         TestCase.assertNotNull(obj);
177
178         checkRawType(obj.getType(), classVersionPairs);
179
180         RawObject superObj = obj.getSuper();
181         for (int i = 2; i < classVersionPairs.length; i += 2) {
182             Object JavaDoc[] a = new Object JavaDoc[classVersionPairs.length - i];
183             System.arraycopy(classVersionPairs, i, a, 0, a.length);
184             TestCase.assertNotNull(superObj);
185             checkRawType(superObj.getType(), a);
186             superObj = superObj.getSuper();
187         }
188
189         return obj;
190     }
191
192     /**
193      * Reads a raw object and checks its superclass names and versions.
194      */

195     private static void checkRawType(RawType type,
196                                      Object JavaDoc... classVersionPairs) {
197         TestCase.assertNotNull(type);
198         TestCase.assertNotNull(classVersionPairs);
199         TestCase.assertTrue(classVersionPairs.length % 2 == 0);
200
201         for (int i = 0; i < classVersionPairs.length; i += 2) {
202             String JavaDoc clsName = (String JavaDoc) classVersionPairs[i];
203             int clsVersion = (Integer JavaDoc) classVersionPairs[i + 1];
204             TestCase.assertEquals(clsName, type.getClassName());
205             TestCase.assertEquals(clsVersion, type.getVersion());
206             type = type.getSuperType();
207         }
208         TestCase.assertNull(type);
209     }
210
211     /**
212      * Checks that a raw object contains the specified field values. Does not
213      * check superclass fields.
214      */

215     private static void checkRawFields(RawObject obj,
216                                        Object JavaDoc... nameValuePairs) {
217         TestCase.assertNotNull(obj);
218         TestCase.assertNotNull(obj.getValues());
219         TestCase.assertNotNull(nameValuePairs);
220         TestCase.assertTrue(nameValuePairs.length % 2 == 0);
221
222         Map JavaDoc<String JavaDoc,Object JavaDoc> values = obj.getValues();
223         TestCase.assertEquals(nameValuePairs.length / 2, values.size());
224
225         for (int i = 0; i < nameValuePairs.length; i += 2) {
226             String JavaDoc name = (String JavaDoc) nameValuePairs[i];
227             Object JavaDoc value = nameValuePairs[i + 1];
228             TestCase.assertEquals(name, value, values.get(name));
229         }
230     }
231
232     private static Map JavaDoc<String JavaDoc,Object JavaDoc> makeValues(Object JavaDoc... nameValuePairs) {
233         TestCase.assertTrue(nameValuePairs.length % 2 == 0);
234         Map JavaDoc<String JavaDoc,Object JavaDoc> values = new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
235         for (int i = 0; i < nameValuePairs.length; i += 2) {
236             values.put((String JavaDoc) nameValuePairs[i], nameValuePairs[i + 1]);
237         }
238         return values;
239     }
240
241     /**
242      * Disallow removing an entity class when no Deleter mutation is specified.
243      */

244     static class DeletedEntity1_ClassRemoved_NoMutation extends EvolveCase {
245
246         private static final String JavaDoc NAME =
247             PREFIX + "DeletedEntity1_ClassRemoved";
248
249         @Override JavaDoc
250         public String JavaDoc getStoreOpenException() {
251             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";
252         }
253
254         @Override JavaDoc
255         void checkUnevolvedModel(EntityModel model, Environment env) {
256             checkEntity(true, model, env, NAME, 0, "skey");
257             checkVersions(model, NAME, 0);
258         }
259
260         @Override JavaDoc
261         void readRawObjects(RawStore store,
262                             boolean expectEvolved,
263                             boolean expectUpdated)
264             throws DatabaseException {
265
266             if (expectEvolved) {
267                 TestCase.fail();
268             }
269             RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
270             checkRawFields(obj, "key", 99, "skey", 88);
271         }
272     }
273
274     /**
275      * Allow removing an entity class when a Deleter mutation is specified.
276      */

277     static class DeletedEntity2_ClassRemoved_WithDeleter extends EvolveCase {
278
279         private static final String JavaDoc NAME =
280             PREFIX + "DeletedEntity2_ClassRemoved";
281
282         @Override JavaDoc
283         int getNRecordsExpected() {
284             return 0;
285         }
286
287         @Override JavaDoc
288         Mutations getMutations() {
289             Mutations m = new Mutations();
290             m.addDeleter(new Deleter(NAME, 0));
291             return m;
292         }
293
294         @Override JavaDoc
295         void checkEvolvedModel(EntityModel model,
296                                Environment env,
297                                boolean oldTypesExist) {
298             checkEntity(false, model, env, NAME, 0, "skey");
299             if (oldTypesExist) {
300                 checkVersions(model, NAME, 0);
301             }
302         }
303
304         @Override JavaDoc
305         void readRawObjects(RawStore store,
306                             boolean expectEvolved,
307                             boolean expectUpdated)
308             throws DatabaseException {
309
310             if (expectEvolved) {
311                 return;
312             }
313             RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
314             checkRawFields(obj, "key", 99, "skey", 88);
315         }
316     }
317
318     /**
319      * Disallow removing the Entity annotation when no Deleter mutation is
320      * specified.
321      */

322     static class DeletedEntity3_AnnotRemoved_NoMutation extends EvolveCase {
323
324         private static final String JavaDoc NAME =
325             DeletedEntity3_AnnotRemoved_NoMutation.class.getName();
326
327         @Override JavaDoc
328         public String JavaDoc getStoreOpenException() {
329             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 is not persistent: com.sleepycat.persist.test.EvolveClasses$DeletedEntity3_AnnotRemoved_NoMutation";
330         }
331
332         @Override JavaDoc
333         void checkUnevolvedModel(EntityModel model, Environment env) {
334             checkEntity(true, model, env, NAME, 0, "skey");
335             checkVersions(model, NAME, 0);
336         }
337
338         @Override JavaDoc
339         void readRawObjects(RawStore store,
340                             boolean expectEvolved,
341                             boolean expectUpdated)
342             throws DatabaseException {
343
344             if (expectEvolved) {
345                 TestCase.fail();
346             }
347             RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
348             checkRawFields(obj, "key", 99, "skey", 88);
349         }
350     }
351
352     /**
353      * Allow removing the Entity annotation when a Deleter mutation is
354      * specified.
355      */

356     static class DeletedEntity4_AnnotRemoved_WithDeleter extends EvolveCase {
357
358         private static final String JavaDoc NAME =
359             DeletedEntity4_AnnotRemoved_WithDeleter.class.getName();
360
361         @Override JavaDoc
362         int getNRecordsExpected() {
363             return 0;
364         }
365
366         @Override JavaDoc
367         Mutations getMutations() {
368             Mutations m = new Mutations();
369             m.addDeleter(new Deleter(NAME, 0));
370             return m;
371         }
372
373         @Override JavaDoc
374         void checkEvolvedModel(EntityModel model,
375                                Environment env,
376                                boolean oldTypesExist) {
377             checkEntity(false, model, env, NAME, 0, "skey");
378             if (oldTypesExist) {
379                 checkVersions(model, NAME, 0);
380             }
381         }
382
383         @Override JavaDoc
384         void readObjects(EntityStore store, boolean doUpdate)
385             throws DatabaseException {
386
387             try {
388                 store.getPrimaryIndex
389                     (Integer JavaDoc.class,
390                      DeletedEntity4_AnnotRemoved_WithDeleter.class);
391                 TestCase.fail();
392             } catch (Exception JavaDoc e) {
393                 checkEquals
394                     ("java.lang.IllegalArgumentException: Not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity4_AnnotRemoved_WithDeleter",
395                      e.toString());
396             }
397         }
398
399         @Override JavaDoc
400         void readRawObjects(RawStore store,
401                             boolean expectEvolved,
402                             boolean expectUpdated)
403             throws DatabaseException {
404
405             if (expectEvolved) {
406                 return;
407             }
408             RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
409             checkRawFields(obj, "key", 99, "skey", 88);
410         }
411     }
412
413     /**
414      * Disallow changing the Entity annotation to Persistent when no Deleter
415      * mutation is specified.
416      */

417     @Persistent(version=1)
418     static class DeletedEntity5_EntityToPersist_NoMutation extends EvolveCase {
419
420         private static final String JavaDoc NAME =
421             DeletedEntity5_EntityToPersist_NoMutation.class.getName();
422
423         @Override JavaDoc
424         public String JavaDoc getStoreOpenException() {
425             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";
426         }
427
428         @Override JavaDoc
429         void checkUnevolvedModel(EntityModel model, Environment env) {
430             checkEntity(true, model, env, NAME, 0, "skey");
431             checkVersions(model, NAME, 0);
432         }
433
434         @Override JavaDoc
435         void readRawObjects(RawStore store,
436                             boolean expectEvolved,
437                             boolean expectUpdated)
438             throws DatabaseException {
439
440             if (expectEvolved) {
441                 TestCase.fail();
442             }
443             RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
444             checkRawFields(obj, "key", 99, "skey", 88);
445         }
446     }
447
448     /**
449      * Allow changing the Entity annotation to Persistent when a Deleter
450      * mutation is specified.
451      */

452     @Persistent(version=1)
453     static class DeletedEntity6_EntityToPersist_WithDeleter extends EvolveCase {
454
455         private static final String JavaDoc NAME =
456             DeletedEntity6_EntityToPersist_WithDeleter.class.getName();
457         private static final String JavaDoc NAME2 =
458             Embed_DeletedEntity6_EntityToPersist_WithDeleter.class.getName();
459
460         @Override JavaDoc
461         int getNRecordsExpected() {
462             return 0;
463         }
464
465         @Override JavaDoc
466         Mutations getMutations() {
467             Mutations m = new Mutations();
468             m.addDeleter(new Deleter(NAME, 0));
469             return m;
470         }
471
472         @Override JavaDoc
473         void checkEvolvedModel(EntityModel model,
474                                Environment env,
475                                boolean oldTypesExist) {
476             checkNonEntity(true, model, env, NAME, 1);
477             if (oldTypesExist) {
478                 checkVersions(model, NAME, 1, NAME, 0);
479             } else {
480                 checkVersions(model, NAME, 1);
481             }
482         }
483
484         @Override JavaDoc
485         void readObjects(EntityStore store, boolean doUpdate)
486             throws DatabaseException {
487
488             /* Cannot get the primary index for the former entity class. */
489             try {
490                 store.getPrimaryIndex
491                     (Integer JavaDoc.class,
492                      DeletedEntity6_EntityToPersist_WithDeleter.class);
493                 TestCase.fail();
494             } catch (Exception JavaDoc e) {
495                 checkEquals
496                     ("java.lang.IllegalArgumentException: Not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity6_EntityToPersist_WithDeleter",
497                      e.toString());
498             }
499
500             /* Can embed the now persistent class in another entity class. */
501             PrimaryIndex<Long JavaDoc,
502                          Embed_DeletedEntity6_EntityToPersist_WithDeleter>
503                 index = store.getPrimaryIndex
504                     (Long JavaDoc.class,
505                      Embed_DeletedEntity6_EntityToPersist_WithDeleter.class);
506
507             if (doUpdate) {
508                 Embed_DeletedEntity6_EntityToPersist_WithDeleter embed =
509                     new Embed_DeletedEntity6_EntityToPersist_WithDeleter();
510                 index.put(embed);
511                 embed = index.get(embed.key);
512                 /* This new type should exist only after update. */
513                 Environment env = store.getEnvironment();
514                 EntityModel model = store.getModel();
515                 checkEntity(true, model, env, NAME2, 0, null);
516                 checkVersions(model, NAME2, 0);
517             }
518         }
519
520         @Override JavaDoc
521         void readRawObjects(RawStore store,
522                             boolean expectEvolved,
523                             boolean expectUpdated)
524             throws DatabaseException {
525
526             if (expectEvolved) {
527                 return;
528             }
529             RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
530             checkRawFields(obj, "key", 99, "skey", 88);
531         }
532     }
533
534     @Entity
535     static class Embed_DeletedEntity6_EntityToPersist_WithDeleter {
536
537         @PrimaryKey
538         long key = 99;
539
540         DeletedEntity6_EntityToPersist_WithDeleter embedded =
541             new DeletedEntity6_EntityToPersist_WithDeleter();
542     }
543
544     /**
545      * Disallow removing a Persistent class when no Deleter mutation is
546      * specified, even when the Entity class that embedded the Persistent class
547      * is deleted properly (by removing the Entity annotation in this case).
548      */

549     static class DeletedPersist1_ClassRemoved_NoMutation extends EvolveCase {
550
551         private static final String JavaDoc NAME =
552             PREFIX + "DeletedPersist1_ClassRemoved";
553
554         private static final String JavaDoc NAME2 =
555             DeletedPersist1_ClassRemoved_NoMutation.class.getName();
556
557         @Override JavaDoc
558         Mutations getMutations() {
559             Mutations m = new Mutations();
560             m.addDeleter(new Deleter(NAME2, 0));
561             return m;
562         }
563
564         @Override JavaDoc
565         public String JavaDoc getStoreOpenException() {
566             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";
567         }
568
569         @Override JavaDoc
570         void checkUnevolvedModel(EntityModel model, Environment env) {
571             checkNonEntity(true, model, env, NAME, 0);
572             checkEntity(true, model, env, NAME2, 0, null);
573             checkVersions(model, NAME, 0);
574             checkVersions(model, NAME2, 0);
575         }
576
577         @Override JavaDoc
578         void readRawObjects(RawStore store,
579                             boolean expectEvolved,
580                             boolean expectUpdated)
581             throws DatabaseException {
582
583             if (expectEvolved) {
584                 TestCase.fail();
585             }
586
587             RawType embedType = store.getModel().getRawType(NAME);
588             checkRawType(embedType, NAME, 0);
589
590             RawObject embed =
591                 new RawObject(embedType, makeValues("f", 123), null);
592
593             RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
594             checkRawFields(obj, "key", 99, "embed", embed);
595         }
596     }
597
598     /**
599      * Allow removing a Persistent class when a Deleter mutation is
600      * specified, and the Entity class that embedded the Persistent class
601      * is also be deleted properly (by removing the Entity annotation in this
602      * case).
603      */

604     static class DeletedPersist2_ClassRemoved_WithDeleter extends EvolveCase {
605
606         private static final String JavaDoc NAME =
607             PREFIX + "DeletedPersist2_ClassRemoved";
608         private static final String JavaDoc NAME2 =
609             DeletedPersist2_ClassRemoved_WithDeleter.class.getName();
610
611         @Override JavaDoc
612         int getNRecordsExpected() {
613             return 0;
614         }
615
616         @Override JavaDoc
617         Mutations getMutations() {
618             Mutations m = new Mutations();
619             m.addDeleter(new Deleter(NAME, 0));
620             m.addDeleter(new Deleter(NAME2, 0));
621             return m;
622         }
623
624         @Override JavaDoc
625         void checkEvolvedModel(EntityModel model,
626                                Environment env,
627                                boolean oldTypesExist) {
628             checkNonEntity(false, model, env, NAME, 0);
629             checkEntity(false, model, env, NAME2, 0, null);
630             if (oldTypesExist) {
631                 checkVersions(model, NAME, 0);
632                 checkVersions(model, NAME2, 0);
633             }
634         }
635
636         @Override JavaDoc
637         void readObjects(EntityStore store, boolean doUpdate)
638             throws DatabaseException {
639
640             try {
641                 store.getPrimaryIndex
642                     (Integer JavaDoc.class,
643                      DeletedPersist2_ClassRemoved_WithDeleter.class);
644                 TestCase.fail();
645             } catch (Exception JavaDoc e) {
646                 checkEquals
647                     ("java.lang.IllegalArgumentException: Not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist2_ClassRemoved_WithDeleter",
648                      e.toString());
649             }
650         }
651
652         @Override JavaDoc
653         void readRawObjects(RawStore store,
654                             boolean expectEvolved,
655                             boolean expectUpdated)
656             throws DatabaseException {
657
658             if (expectEvolved) {
659                 return;
660             }
661
662             RawType embedType = store.getModel().getRawType(NAME);
663             checkRawType(embedType, NAME, 0);
664
665             RawObject embed =
666                 new RawObject(embedType, makeValues("f", 123), null);
667
668             RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
669             checkRawFields(obj, "key", 99, "embed", embed);
670         }
671     }
672
673     static class DeletedPersist3_AnnotRemoved {
674
675         int f = 123;
676     }
677
678     /**
679      * Disallow removing the Persistent annotation when no Deleter mutation is
680      * specified, even when the Entity class that embedded the Persistent class
681      * is deleted properly (by removing the Entity annotation in this case).
682      */

683     static class DeletedPersist3_AnnotRemoved_NoMutation extends EvolveCase {
684
685         private static final String JavaDoc NAME =
686             DeletedPersist3_AnnotRemoved.class.getName();
687         private static final String JavaDoc NAME2 =
688             DeletedPersist3_AnnotRemoved_NoMutation.class.getName();
689
690         @Override JavaDoc
691         Mutations getMutations() {
692             Mutations m = new Mutations();
693             m.addDeleter(new Deleter(NAME2, 0));
694             return m;
695         }
696
697         @Override JavaDoc
698         public String JavaDoc getStoreOpenException() {
699             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 is not persistent: com.sleepycat.persist.test.EvolveClasses$DeletedPersist3_AnnotRemoved";
700         }
701
702         @Override JavaDoc
703         void checkUnevolvedModel(EntityModel model, Environment env) {
704             checkNonEntity(true, model, env, NAME, 0);
705             checkEntity(true, model, env, NAME2, 0, null);
706             checkVersions(model, NAME, 0);
707             checkVersions(model, NAME2, 0);
708         }
709
710         @Override JavaDoc
711         void readRawObjects(RawStore store,
712                             boolean expectEvolved,
713                             boolean expectUpdated)
714             throws DatabaseException {
715
716             if (expectEvolved) {
717                 TestCase.fail();
718             }
719
720             RawType embedType = store.getModel().getRawType(NAME);
721             checkRawType(embedType, NAME, 0);
722
723             RawObject embed =
724                 new RawObject(embedType, makeValues("f", 123), null);
725
726             RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
727             checkRawFields(obj, "key", 99, "embed", embed);
728         }
729     }
730
731     static class DeletedPersist4_AnnotRemoved {
732
733         int f = 123;
734     }
735
736     /**
737      * Allow removing the Persistent annotation when a Deleter mutation is
738      * specified, and the Entity class that embedded the Persistent class
739      * is also be deleted properly (by removing the Entity annotation in this
740      * case).
741      */

742     static class DeletedPersist4_AnnotRemoved_WithDeleter extends EvolveCase {
743
744         private static final String JavaDoc NAME =
745             DeletedPersist4_AnnotRemoved.class.getName();
746         private static final String JavaDoc NAME2 =
747             DeletedPersist4_AnnotRemoved_WithDeleter.class.getName();
748
749         @Override JavaDoc
750         int getNRecordsExpected() {
751             return 0;
752         }
753
754         @Override JavaDoc
755         Mutations getMutations() {
756             Mutations m = new Mutations();
757             m.addDeleter(new Deleter(NAME, 0));
758             m.addDeleter(new Deleter(NAME2, 0));
759             return m;
760         }
761
762         @Override JavaDoc
763         void checkEvolvedModel(EntityModel model,
764                                Environment env,
765                                boolean oldTypesExist) {
766             checkNonEntity(false, model, env, NAME, 0);
767             checkEntity(false, model, env, NAME2, 0, null);
768             if (oldTypesExist) {
769                 checkVersions(model, NAME, 0);
770                 checkVersions(model, NAME2, 0);
771             }
772         }
773
774         @Override JavaDoc
775         void readObjects(EntityStore store, boolean doUpdate)
776             throws DatabaseException {
777
778             try {
779                 store.getPrimaryIndex
780                     (Integer JavaDoc.class,
781                      DeletedPersist4_AnnotRemoved_WithDeleter.class);
782                 TestCase.fail();
783             } catch (Exception JavaDoc e) {
784                 checkEquals
785                     ("java.lang.IllegalArgumentException: Not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist4_AnnotRemoved_WithDeleter",
786                      e.toString());
787             }
788         }
789
790         @Override JavaDoc
791         void readRawObjects(RawStore store,
792                             boolean expectEvolved,
793                             boolean expectUpdated)
794             throws DatabaseException {
795
796             if (expectEvolved) {
797                 return;
798             }
799
800             RawType embedType = store.getModel().getRawType(NAME);
801             checkRawType(embedType, NAME, 0);
802
803             RawObject embed =
804                 new RawObject(embedType, makeValues("f", 123), null);
805
806             RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
807             checkRawFields(obj, "key", 99, "embed", embed);
808         }
809     }
810
811     @Entity(version=1)
812     static class DeletedPersist5_PersistToEntity {
813
814         @PrimaryKey
815         int key = 99;
816
817         int f = 123;
818     }
819
820     /**
821      * Disallow changing the Entity annotation to Persistent when no Deleter
822      * mutation is specified, even when the Entity class that embedded the
823      * Persistent class is deleted properly (by removing the Entity annotation
824      * in this case).
825      */

826     static class DeletedPersist5_PersistToEntity_NoMutation
827         extends EvolveCase {
828
829         private static final String JavaDoc NAME =
830             DeletedPersist5_PersistToEntity.class.getName();
831         private static final String JavaDoc NAME2 =
832             DeletedPersist5_PersistToEntity_NoMutation.class.getName();
833
834         @Override JavaDoc
835         Mutations getMutations() {
836             Mutations m = new Mutations();
837             m.addDeleter(new Deleter(NAME2, 0));
838             return m;
839         }
840
841         @Override JavaDoc
842         public String JavaDoc getStoreOpenException() {
843             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";
844         }
845
846         @Override JavaDoc
847         void checkUnevolvedModel(EntityModel model, Environment env) {
848             checkNonEntity(true, model, env, NAME, 0);
849             checkEntity(true, model, env, NAME2, 0, null);
850             checkVersions(model, NAME, 0);
851             checkVersions(model, NAME2, 0);
852         }
853
854         @Override JavaDoc
855         void readRawObjects(RawStore store,
856                             boolean expectEvolved,
857                             boolean expectUpdated)
858             throws DatabaseException {
859
860             if (expectEvolved) {
861                 TestCase.fail();
862             }
863
864             RawType embedType = store.getModel().getRawType(NAME);
865             checkRawType(embedType, NAME, 0);
866
867             RawObject embed =
868                 new RawObject(embedType, makeValues("f", 123), null);
869
870             RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
871             checkRawFields(obj, "key", 99, "embed", embed);
872         }
873     }
874
875     @Entity(version=1)
876     static class DeletedPersist6_PersistToEntity {
877
878         @PrimaryKey
879         int key = 99;
880
881         int f = 123;
882     }
883
884     /**
885      * Allow changing the Entity annotation to Persistent when a Deleter
886      * mutation is specified, and the Entity class that embedded the Persistent
887      * class is also be deleted properly (by removing the Entity annotation in
888      * this case).
889      */

890     static class DeletedPersist6_PersistToEntity_WithDeleter
891         extends EvolveCase {
892
893         private static final String JavaDoc NAME =
894             DeletedPersist6_PersistToEntity.class.getName();
895         private static final String JavaDoc NAME2 =
896             DeletedPersist6_PersistToEntity_WithDeleter.class.getName();
897
898         @Override JavaDoc
899         int getNRecordsExpected() {
900             return 0;
901         }
902
903         @Override JavaDoc
904         Mutations getMutations() {
905             Mutations m = new Mutations();
906             m.addDeleter(new Deleter(NAME, 0));
907             m.addDeleter(new Deleter(NAME2, 0));
908             return m;
909         }
910
911         @Override JavaDoc
912         void checkEvolvedModel(EntityModel model,
913                                Environment env,
914                                boolean oldTypesExist) {
915             checkEntity(false, model, env, NAME2, 0, null);
916             if (oldTypesExist) {
917                 checkVersions(model, NAME, 1, NAME, 0);
918                 checkVersions(model, NAME2, 0);
919             } else {
920                 checkVersions(model, NAME, 1);
921             }
922         }
923
924         @Override JavaDoc
925         void readObjects(EntityStore store, boolean doUpdate)
926             throws DatabaseException {
927
928             /* Cannot get the primary index for the former entity class. */
929             try {
930                 store.getPrimaryIndex
931                     (Integer JavaDoc.class,
932                      DeletedPersist6_PersistToEntity_WithDeleter.class);
933                 TestCase.fail();
934             } catch (Exception JavaDoc e) {
935                 checkEquals
936                     ("java.lang.IllegalArgumentException: Not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist6_PersistToEntity_WithDeleter",
937                      e.toString());
938             }
939
940             /* Can use the primary index of the now entity class. */
941             PrimaryIndex<Integer JavaDoc,
942                          DeletedPersist6_PersistToEntity>
943                 index = store.getPrimaryIndex
944                     (Integer JavaDoc.class,
945                      DeletedPersist6_PersistToEntity.class);
946
947             if (doUpdate) {
948                 DeletedPersist6_PersistToEntity obj =
949                     new DeletedPersist6_PersistToEntity();
950                 index.put(obj);
951                 obj = index.get(obj.key);
952                 /* This new type should exist only after update. */
953                 Environment env = store.getEnvironment();
954                 EntityModel model = store.getModel();
955                 checkEntity(true, model, env, NAME, 1, null);
956             }
957         }
958
959         @Override JavaDoc
960         void copyRawObjects(RawStore rawStore, EntityStore newStore)
961             throws DatabaseException {
962
963             PrimaryIndex<Integer JavaDoc,
964                          DeletedPersist6_PersistToEntity>
965                 index = newStore.getPrimaryIndex
966                     (Integer JavaDoc.class,
967                      DeletedPersist6_PersistToEntity.class);
968             RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
969             index.put((DeletedPersist6_PersistToEntity)
970                       newStore.getModel().convertRawObject(raw));
971         }
972
973         @Override JavaDoc
974         void readRawObjects(RawStore store,
975                             boolean expectEvolved,
976                             boolean expectUpdated)
977             throws DatabaseException {
978
979             if (expectEvolved) {
980                 return;
981             }
982
983             RawType embedType = store.getModel().getRawType(NAME);
984             checkRawType(embedType, NAME, 0);
985
986             RawObject embed =
987                 new RawObject(embedType, makeValues("f", 123), null);
988
989             RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
990             checkRawFields(obj, "key", 99, "embed", embed);
991         }
992     }
993
994     /**
995      * Disallow renaming an entity class without a Renamer mutation.
996      */

997     @Entity(version=1)
998     static class RenamedEntity1_NewEntityName_NoMutation
999         extends EvolveCase {
1000
1001        private static final String JavaDoc NAME =
1002            PREFIX + "RenamedEntity1_NewEntityName";
1003        private static final String JavaDoc NAME2 =
1004            RenamedEntity1_NewEntityName_NoMutation.class.getName();
1005
1006        @PrimaryKey
1007        int key = 99;
1008
1009        @SecondaryKey(relate=ONE_TO_ONE)
1010        int skey = 88;
1011
1012        @Override JavaDoc
1013        public String JavaDoc getStoreOpenException() {
1014            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";
1015        }
1016
1017        @Override JavaDoc
1018        void checkUnevolvedModel(EntityModel model, Environment env) {
1019            checkEntity(true, model, env, NAME, 0, "skey");
1020            checkVersions(model, NAME, 0);
1021        }
1022
1023        @Override JavaDoc
1024        void readRawObjects(RawStore store,
1025                            boolean expectEvolved,
1026                            boolean expectUpdated)
1027            throws DatabaseException {
1028
1029            if (expectEvolved) {
1030                TestCase.fail();
1031            }
1032            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1033            checkRawFields(obj, "key", 99, "skey", 88);
1034        }
1035    }
1036
1037    /**
1038     * Allow renaming an entity class with a Renamer mutation.
1039     */

1040    @Entity(version=1)
1041    static class RenamedEntity2_NewEntityName_WithRenamer
1042        extends EvolveCase {
1043
1044        private static final String JavaDoc NAME =
1045            PREFIX + "RenamedEntity2_NewEntityName";
1046        private static final String JavaDoc NAME2 =
1047            RenamedEntity2_NewEntityName_WithRenamer.class.getName();
1048
1049        @PrimaryKey
1050        int key = 99;
1051
1052        @SecondaryKey(relate=ONE_TO_ONE)
1053        int skey = 88;
1054
1055        @Override JavaDoc
1056        Mutations getMutations() {
1057            Mutations m = new Mutations();
1058            m.addRenamer(new Renamer(NAME, 0, NAME2));
1059            return m;
1060        }
1061
1062        @Override JavaDoc
1063        void checkEvolvedModel(EntityModel model,
1064                               Environment env,
1065                               boolean oldTypesExist) {
1066            checkEntity(false, model, env, NAME, 0, null);
1067            checkEntity(true, model, env, NAME2, 1, null);
1068            if (oldTypesExist) {
1069                checkVersions(model, NAME2, 1, NAME, 0);
1070            } else {
1071                checkVersions(model, NAME2, 1);
1072            }
1073        }
1074
1075        @Override JavaDoc
1076        void readObjects(EntityStore store, boolean doUpdate)
1077            throws DatabaseException {
1078
1079            PrimaryIndex<Integer JavaDoc,RenamedEntity2_NewEntityName_WithRenamer>
1080                index = store.getPrimaryIndex
1081                    (Integer JavaDoc.class,
1082                     RenamedEntity2_NewEntityName_WithRenamer.class);
1083            RenamedEntity2_NewEntityName_WithRenamer obj = index.get(key);
1084            TestCase.assertNotNull(obj);
1085            TestCase.assertEquals(99, obj.key);
1086            TestCase.assertEquals(88, obj.skey);
1087
1088            SecondaryIndex<Integer JavaDoc,Integer JavaDoc,
1089                           RenamedEntity2_NewEntityName_WithRenamer>
1090                sindex = store.getSecondaryIndex(index, Integer JavaDoc.class, "skey");
1091            obj = sindex.get(88);
1092            TestCase.assertNotNull(obj);
1093            TestCase.assertEquals(99, obj.key);
1094            TestCase.assertEquals(88, obj.skey);
1095
1096            if (doUpdate) {
1097                index.put(obj);
1098            }
1099        }
1100
1101        @Override JavaDoc
1102        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1103            throws DatabaseException {
1104
1105            PrimaryIndex<Integer JavaDoc,RenamedEntity2_NewEntityName_WithRenamer>
1106                index = newStore.getPrimaryIndex
1107                    (Integer JavaDoc.class,
1108                     RenamedEntity2_NewEntityName_WithRenamer.class);
1109            RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1110            index.put((RenamedEntity2_NewEntityName_WithRenamer)
1111                      newStore.getModel().convertRawObject(raw));
1112        }
1113
1114        @Override JavaDoc
1115        void readRawObjects(RawStore store,
1116                            boolean expectEvolved,
1117                            boolean expectUpdated)
1118            throws DatabaseException {
1119
1120            RawObject obj;
1121            if (expectEvolved) {
1122                obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1123            } else {
1124                obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1125            }
1126            checkRawFields(obj, "key", 99, "skey", 88);
1127        }
1128    }
1129
1130    @Persistent
1131    static class DeleteSuperclass1_BaseClass
1132        extends EvolveCase {
1133
1134        int f = 123;
1135    }
1136
1137    /**
1138     * Disallow deleting a superclass from the hierarchy when the superclass
1139     * has persistent fields and no Deleter or Converter is specified.
1140     */

1141    @Entity
1142    static class DeleteSuperclass1_NoMutation
1143        extends EvolveCase {
1144
1145        private static final String JavaDoc NAME =
1146            DeleteSuperclass1_BaseClass.class.getName();
1147        private static final String JavaDoc NAME2 =
1148            DeleteSuperclass1_NoMutation.class.getName();
1149
1150        @PrimaryKey
1151        int key = 99;
1152
1153        int ff;
1154
1155        @Override JavaDoc
1156        public String JavaDoc getStoreOpenException() {
1157            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";
1158        }
1159
1160        @Override JavaDoc
1161        void checkUnevolvedModel(EntityModel model, Environment env) {
1162            checkNonEntity(true, model, env, NAME, 0);
1163            checkEntity(true, model, env, NAME2, 0, null);
1164            checkVersions(model, NAME, 0);
1165            checkVersions(model, NAME2, 0);
1166        }
1167
1168        @Override JavaDoc
1169        void readRawObjects(RawStore store,
1170                            boolean expectEvolved,
1171                            boolean expectUpdated)
1172            throws DatabaseException {
1173
1174            if (expectEvolved) {
1175                TestCase.fail();
1176            }
1177            RawObject obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1178            checkRawFields(obj, "key", 99, "ff", 88);
1179            checkRawFields(obj.getSuper(), "f", 123);
1180            checkRawFields(obj.getSuper().getSuper());
1181        }
1182    }
1183
1184    @Persistent
1185    static class DeleteSuperclass2_BaseClass
1186        extends EvolveCase {
1187
1188        int f;
1189
1190        @SecondaryKey(relate=ONE_TO_ONE)
1191        int skey;
1192    }
1193
1194    /**
1195     * Allow deleting a superclass from the hierarchy when the superclass has
1196     * persistent fields and a class Converter is specified. Also check that
1197     * the secondary key field in the deleted base class is handled properly.
1198     */

1199    @Entity(version=1)
1200    static class DeleteSuperclass2_WithConverter extends EvolveCase {
1201
1202        private static final String JavaDoc NAME =
1203            DeleteSuperclass2_BaseClass.class.getName();
1204        private static final String JavaDoc NAME2 =
1205            DeleteSuperclass2_WithConverter.class.getName();
1206
1207        @PrimaryKey
1208        int key;
1209
1210        int ff;
1211
1212        @SecondaryKey(relate=ONE_TO_ONE)
1213        Integer JavaDoc skey2;
1214
1215        @SecondaryKey(relate=ONE_TO_ONE)
1216        int skey3;
1217
1218        @Override JavaDoc
1219        Mutations getMutations() {
1220            Mutations m = new Mutations();
1221            m.addConverter(new EntityConverter
1222                (NAME2, 0, new MyConversion(),
1223                 Collections.singleton("skey")));
1224            return m;
1225        }
1226
1227        static class MyConversion implements Conversion {
1228
1229            transient RawType newType;
1230
1231            public void initialize(EntityModel model) {
1232                newType = model.getRawType(NAME2);
1233                TestCase.assertNotNull(newType);
1234            }
1235
1236            public Object JavaDoc convert(Object JavaDoc fromValue) {
1237                TestCase.assertNotNull(newType);
1238                RawObject obj = (RawObject) fromValue;
1239                RawObject newSuper = obj.getSuper().getSuper();
1240                return new RawObject(newType, obj.getValues(), newSuper);
1241            }
1242
1243            @Override JavaDoc
1244            public boolean equals(Object JavaDoc other) {
1245                return other instanceof MyConversion;
1246            }
1247        }
1248
1249        @Override JavaDoc
1250        void checkEvolvedModel(EntityModel model,
1251                               Environment env,
1252                               boolean oldTypesExist) {
1253            checkEntity(true, model, env, NAME2, 1, null);
1254            if (oldTypesExist) {
1255                checkVersions(model, NAME2, 1, NAME2, 0);
1256                checkNonEntity(true, model, env, NAME, 0);
1257                checkVersions(model, NAME, 0);
1258            } else {
1259                checkVersions(model, NAME2, 1);
1260            }
1261        }
1262
1263        @Override JavaDoc
1264        void readObjects(EntityStore store, boolean doUpdate)
1265            throws DatabaseException {
1266
1267            PrimaryIndex<Integer JavaDoc,DeleteSuperclass2_WithConverter>
1268                index = store.getPrimaryIndex
1269                    (Integer JavaDoc.class,
1270                     DeleteSuperclass2_WithConverter.class);
1271            DeleteSuperclass2_WithConverter obj = index.get(99);
1272            TestCase.assertNotNull(obj);
1273            TestCase.assertSame
1274                (EvolveCase.class, obj.getClass().getSuperclass());
1275            TestCase.assertEquals(99, obj.key);
1276            TestCase.assertEquals(88, obj.ff);
1277            TestCase.assertEquals(Integer.valueOf(77), obj.skey2);
1278            TestCase.assertEquals(66, obj.skey3);
1279            if (doUpdate) {
1280                index.put(obj);
1281            }
1282        }
1283
1284        @Override JavaDoc
1285        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1286            throws DatabaseException {
1287
1288            PrimaryIndex<Integer JavaDoc,DeleteSuperclass2_WithConverter>
1289                index = newStore.getPrimaryIndex
1290                    (Integer JavaDoc.class,
1291                     DeleteSuperclass2_WithConverter.class);
1292            RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1293            index.put((DeleteSuperclass2_WithConverter)
1294                      newStore.getModel().convertRawObject(raw));
1295        }
1296
1297        @Override JavaDoc
1298        void readRawObjects(RawStore store,
1299                            boolean expectEvolved,
1300                            boolean expectUpdated)
1301            throws DatabaseException {
1302
1303            RawObject obj;
1304            if (expectEvolved) {
1305                obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1306            } else {
1307                obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1308            }
1309            checkRawFields
1310                (obj, "key", 99, "ff", 88, "skey2", 77, "skey3", 66);
1311            if (expectEvolved) {
1312                checkRawFields(obj.getSuper());
1313            } else {
1314                checkRawFields(obj.getSuper(), "f", 123, "skey", 456);
1315                checkRawFields(obj.getSuper().getSuper());
1316            }
1317            Environment env = store.getEnvironment();
1318            assertDbExists(!expectEvolved, env, NAME2, "skey");
1319            assertDbExists(true, env, NAME2, "skey3");
1320        }
1321    }
1322
1323    static class DeleteSuperclass3_BaseClass
1324        extends EvolveCase {
1325
1326        int f;
1327
1328        @SecondaryKey(relate=ONE_TO_ONE)
1329        int skey;
1330    }
1331
1332    /**
1333     * Allow deleting a superclass from the hierarchy when the superclass
1334     * has persistent fields and a class Deleter is specified. Also check that
1335     * the secondary key field in the deleted base class is handled properly.
1336     */

1337    @Entity(version=1)
1338    static class DeleteSuperclass3_WithDeleter extends EvolveCase {
1339
1340        private static final String JavaDoc NAME =
1341            DeleteSuperclass3_BaseClass.class.getName();
1342        private static final String JavaDoc NAME2 =
1343            DeleteSuperclass3_WithDeleter.class.getName();
1344
1345        @PrimaryKey
1346        int key;
1347
1348        int ff;
1349
1350        @Override JavaDoc
1351        Mutations getMutations() {
1352            Mutations m = new Mutations();
1353            m.addDeleter(new Deleter(NAME, 0));
1354            return m;
1355        }
1356
1357        @Override JavaDoc
1358        void checkEvolvedModel(EntityModel model,
1359                               Environment env,
1360                               boolean oldTypesExist) {
1361            checkEntity(true, model, env, NAME2, 1, null);
1362            if (oldTypesExist) {
1363                checkVersions(model, NAME2, 1, NAME2, 0);
1364                checkNonEntity(false, model, env, NAME, 0);
1365                checkVersions(model, NAME, 0);
1366            } else {
1367                checkVersions(model, NAME2, 1);
1368            }
1369        }
1370
1371        @Override JavaDoc
1372        void readObjects(EntityStore store, boolean doUpdate)
1373            throws DatabaseException {
1374
1375            PrimaryIndex<Integer JavaDoc,DeleteSuperclass3_WithDeleter>
1376                index = store.getPrimaryIndex
1377                    (Integer JavaDoc.class,
1378                     DeleteSuperclass3_WithDeleter.class);
1379            DeleteSuperclass3_WithDeleter obj = index.get(99);
1380            TestCase.assertNotNull(obj);
1381            TestCase.assertSame
1382                (EvolveCase.class, obj.getClass().getSuperclass());
1383            TestCase.assertEquals(99, obj.key);
1384            TestCase.assertEquals(88, obj.ff);
1385            if (doUpdate) {
1386                index.put(obj);
1387            }
1388        }
1389
1390        @Override JavaDoc
1391        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1392            throws DatabaseException {
1393
1394            PrimaryIndex<Integer JavaDoc,DeleteSuperclass3_WithDeleter>
1395                index = newStore.getPrimaryIndex
1396                    (Integer JavaDoc.class,
1397                     DeleteSuperclass3_WithDeleter.class);
1398            RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1399            index.put((DeleteSuperclass3_WithDeleter)
1400                      newStore.getModel().convertRawObject(raw));
1401        }
1402
1403        @Override JavaDoc
1404        void readRawObjects(RawStore store,
1405                            boolean expectEvolved,
1406                            boolean expectUpdated)
1407            throws DatabaseException {
1408
1409            RawObject obj;
1410            if (expectEvolved) {
1411                obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1412            } else {
1413                obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1414            }
1415            checkRawFields(obj, "key", 99, "ff", 88);
1416            if (expectEvolved) {
1417                checkRawFields(obj.getSuper());
1418            } else {
1419                checkRawFields(obj.getSuper(), "f", 123, "skey", 456);
1420                checkRawFields(obj.getSuper().getSuper());
1421            }
1422            Environment env = store.getEnvironment();
1423            assertDbExists(!expectEvolved, env, NAME2, "skey");
1424        }
1425    }
1426
1427    @Persistent
1428    static class DeleteSuperclass4_BaseClass
1429        extends EvolveCase {
1430    }
1431
1432    /**
1433     * Allow deleting a superclass from the hierarchy when the superclass
1434     * has NO persistent fields. No mutations are needed.
1435     */

1436    @Entity(version=1)
1437    static class DeleteSuperclass4_NoFields extends EvolveCase {
1438
1439        private static final String JavaDoc NAME =
1440            DeleteSuperclass4_BaseClass.class.getName();
1441        private static final String JavaDoc NAME2 =
1442            DeleteSuperclass4_NoFields.class.getName();
1443
1444        @PrimaryKey
1445        int key = 99;
1446
1447        int ff;
1448
1449        @Override JavaDoc
1450        void checkEvolvedModel(EntityModel model,
1451                               Environment env,
1452                               boolean oldTypesExist) {
1453            checkEntity(true, model, env, NAME2, 1, null);
1454            if (oldTypesExist) {
1455                checkVersions(model, NAME2, 1, NAME2, 0);
1456                checkNonEntity(true, model, env, NAME, 0);
1457                checkVersions(model, NAME, 0);
1458            } else {
1459                checkVersions(model, NAME2, 1);
1460            }
1461        }
1462
1463        @Override JavaDoc
1464        void readObjects(EntityStore store, boolean doUpdate)
1465            throws DatabaseException {
1466
1467            PrimaryIndex<Integer JavaDoc,DeleteSuperclass4_NoFields>
1468                index = store.getPrimaryIndex
1469                    (Integer JavaDoc.class,
1470                     DeleteSuperclass4_NoFields.class);
1471            DeleteSuperclass4_NoFields obj = index.get(key);
1472            TestCase.assertNotNull(obj);
1473            TestCase.assertSame
1474                (EvolveCase.class, obj.getClass().getSuperclass());
1475            TestCase.assertEquals(99, obj.key);
1476            TestCase.assertEquals(88, obj.ff);
1477            if (doUpdate) {
1478                index.put(obj);
1479            }
1480        }
1481
1482        @Override JavaDoc
1483        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1484            throws DatabaseException {
1485
1486            PrimaryIndex<Integer JavaDoc,DeleteSuperclass4_NoFields>
1487                index = newStore.getPrimaryIndex
1488                    (Integer JavaDoc.class,
1489                     DeleteSuperclass4_NoFields.class);
1490            RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1491            index.put((DeleteSuperclass4_NoFields)
1492                      newStore.getModel().convertRawObject(raw));
1493        }
1494
1495        @Override JavaDoc
1496        void readRawObjects(RawStore store,
1497                            boolean expectEvolved,
1498                            boolean expectUpdated)
1499            throws DatabaseException {
1500
1501            RawObject obj;
1502            if (expectEvolved) {
1503                obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1504            } else {
1505                obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1506            }
1507            checkRawFields(obj, "key", 99, "ff", 88);
1508            checkRawFields(obj.getSuper());
1509            if (expectEvolved) {
1510                TestCase.assertNull(obj.getSuper().getSuper());
1511            } else {
1512                checkRawFields(obj.getSuper().getSuper());
1513            }
1514        }
1515    }
1516
1517    @Persistent(version=1)
1518    static class DeleteSuperclass5_Embedded {
1519
1520        int f;
1521
1522        @Override JavaDoc
1523        public String JavaDoc toString() {
1524            return "" + f;
1525        }
1526    }
1527
1528    /**
1529     * Ensure that a superclass at the top of the hierarchy can be deleted. A
1530     * class Deleter is used.
1531     */

1532    @Entity
1533    static class DeleteSuperclass5_Top
1534        extends EvolveCase {
1535
1536        private static final String JavaDoc NAME =
1537            DeleteSuperclass5_Top.class.getName();
1538        private static final String JavaDoc NAME2 =
1539            DeleteSuperclass5_Embedded.class.getName();
1540        private static final String JavaDoc NAME3 =
1541            PREFIX + "DeleteSuperclass5_Embedded_Base";
1542
1543        @PrimaryKey
1544        int key = 99;
1545
1546        int ff;
1547
1548        DeleteSuperclass5_Embedded embed =
1549            new DeleteSuperclass5_Embedded();
1550
1551        @Override JavaDoc
1552        Mutations getMutations() {
1553            Mutations m = new Mutations();
1554            m.addDeleter(new Deleter(NAME3, 0));
1555            return m;
1556        }
1557
1558        @Override JavaDoc
1559        void checkEvolvedModel(EntityModel model,
1560                               Environment env,
1561                               boolean oldTypesExist) {
1562            checkEntity(true, model, env, NAME, 0, null);
1563            checkNonEntity(true, model, env, NAME2, 1);
1564            checkNonEntity(false, model, env, NAME3, 0);
1565            checkVersions(model, NAME, 0);
1566            if (oldTypesExist) {
1567                checkVersions(model, NAME2, 1, NAME2, 0);
1568                checkVersions(model, NAME3, 0);
1569            } else {
1570                checkVersions(model, NAME2, 1);
1571            }
1572        }
1573
1574        @Override JavaDoc
1575        void readObjects(EntityStore store, boolean doUpdate)
1576            throws DatabaseException {
1577
1578            PrimaryIndex<Integer JavaDoc,DeleteSuperclass5_Top>
1579                index = store.getPrimaryIndex
1580                    (Integer JavaDoc.class,
1581                     DeleteSuperclass5_Top.class);
1582            DeleteSuperclass5_Top obj = index.get(key);
1583            TestCase.assertNotNull(obj);
1584            TestCase.assertNotNull(obj.embed);
1585            TestCase.assertEquals(99, obj.key);
1586            TestCase.assertEquals(88, obj.ff);
1587            TestCase.assertEquals(123, obj.embed.f);
1588            if (doUpdate) {
1589                index.put(obj);
1590            }
1591        }
1592
1593        @Override JavaDoc
1594        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1595            throws DatabaseException {
1596
1597            PrimaryIndex<Integer JavaDoc,DeleteSuperclass5_Top>
1598                index = newStore.getPrimaryIndex
1599                    (Integer JavaDoc.class,
1600                     DeleteSuperclass5_Top.class);
1601            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
1602            index.put((DeleteSuperclass5_Top)
1603                      newStore.getModel().convertRawObject(raw));
1604        }
1605
1606        @Override JavaDoc
1607        void readRawObjects(RawStore store,
1608                            boolean expectEvolved,
1609                            boolean expectUpdated)
1610            throws DatabaseException {
1611
1612            RawType embedType = store.getModel().getRawType(NAME2);
1613            RawObject embedSuper = null;
1614            if (!expectEvolved) {
1615                RawType embedSuperType = store.getModel().getRawType(NAME3);
1616                embedSuper = new RawObject
1617                    (embedSuperType, makeValues("g", 456), null);
1618            }
1619            RawObject embed =
1620                new RawObject(embedType, makeValues("f", 123), embedSuper);
1621            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1622            checkRawFields(obj, "key", 99, "ff", 88, "embed", embed);
1623        }
1624    }
1625
1626    @Persistent
1627    static class InsertSuperclass1_BaseClass
1628        extends EvolveCase {
1629
1630        int f = 123;
1631    }
1632
1633    /**
1634     * Allow inserting a superclass between two existing classes in the
1635     * hierarchy. No mutations are needed.
1636     */

1637    @Entity(version=1)
1638    static class InsertSuperclass1_Between
1639        extends InsertSuperclass1_BaseClass {
1640
1641        private static final String JavaDoc NAME =
1642            InsertSuperclass1_BaseClass.class.getName();
1643        private static final String JavaDoc NAME2 =
1644            InsertSuperclass1_Between.class.getName();
1645
1646        @PrimaryKey
1647        int key = 99;
1648
1649        int ff;
1650
1651        @Override JavaDoc
1652        void checkEvolvedModel(EntityModel model,
1653                               Environment env,
1654                               boolean oldTypesExist) {
1655            checkNonEntity(true, model, env, NAME, 0);
1656            checkEntity(true, model, env, NAME2, 1, null);
1657            checkVersions(model, NAME, 0);
1658            if (oldTypesExist) {
1659                checkVersions(model, NAME2, 1, NAME2, 0);
1660            } else {
1661                checkVersions(model, NAME2, 1);
1662            }
1663        }
1664
1665        @Override JavaDoc
1666        void readObjects(EntityStore store, boolean doUpdate)
1667            throws DatabaseException {
1668
1669            PrimaryIndex<Integer JavaDoc,InsertSuperclass1_Between>
1670                index = store.getPrimaryIndex
1671                    (Integer JavaDoc.class,
1672                     InsertSuperclass1_Between.class);
1673            InsertSuperclass1_Between obj = index.get(key);
1674            TestCase.assertNotNull(obj);
1675            TestCase.assertSame
1676                (InsertSuperclass1_BaseClass.class,
1677                 obj.getClass().getSuperclass());
1678            TestCase.assertSame
1679                (EvolveCase.class,
1680                 obj.getClass().getSuperclass().getSuperclass());
1681            TestCase.assertEquals(99, obj.key);
1682            TestCase.assertEquals(88, obj.ff);
1683            TestCase.assertEquals(123, obj.f);
1684            if (doUpdate) {
1685                index.put(obj);
1686            }
1687        }
1688
1689        @Override JavaDoc
1690        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1691            throws DatabaseException {
1692
1693            PrimaryIndex<Integer JavaDoc,InsertSuperclass1_Between>
1694                index = newStore.getPrimaryIndex
1695                    (Integer JavaDoc.class,
1696                     InsertSuperclass1_Between.class);
1697            RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1698            index.put((InsertSuperclass1_Between)
1699                      newStore.getModel().convertRawObject(raw));
1700        }
1701
1702        @Override JavaDoc
1703        void readRawObjects(RawStore store,
1704                            boolean expectEvolved,
1705                            boolean expectUpdated)
1706            throws DatabaseException {
1707
1708            RawObject obj;
1709            if (expectEvolved) {
1710                obj = readRaw(store, 99, NAME2, 1, NAME, 0, CASECLS, 0);
1711            } else {
1712                obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
1713            }
1714            checkRawFields(obj, "key", 99, "ff", 88);
1715            if (expectEvolved) {
1716                if (expectUpdated) {
1717                    checkRawFields(obj.getSuper(), "f", 123);
1718                } else {
1719                    checkRawFields(obj.getSuper());
1720                }
1721                checkRawFields(obj.getSuper().getSuper());
1722                TestCase.assertNull(obj.getSuper().getSuper().getSuper());
1723            } else {
1724                checkRawFields(obj.getSuper());
1725                TestCase.assertNull(obj.getSuper().getSuper());
1726            }
1727        }
1728    }
1729
1730    @Persistent
1731    static class InsertSuperclass2_Embedded_Base {
1732
1733        int g = 456;
1734    }
1735
1736    @Persistent(version=1)
1737    static class InsertSuperclass2_Embedded
1738        extends InsertSuperclass2_Embedded_Base {
1739
1740        int f;
1741    }
1742
1743    /**
1744     * Allow inserting a superclass at the top of the hierarchy. No mutations
1745     * are needed.
1746     */

1747    @Entity
1748    static class InsertSuperclass2_Top
1749        extends EvolveCase {
1750
1751        private static final String JavaDoc NAME =
1752            InsertSuperclass2_Top.class.getName();
1753        private static final String JavaDoc NAME2 =
1754            InsertSuperclass2_Embedded.class.getName();
1755        private static final String JavaDoc NAME3 =
1756            InsertSuperclass2_Embedded_Base.class.getName();
1757
1758        @PrimaryKey
1759        int key = 99;
1760
1761        int ff;
1762
1763        InsertSuperclass2_Embedded embed =
1764            new InsertSuperclass2_Embedded();
1765
1766        @Override JavaDoc
1767        void checkEvolvedModel(EntityModel model,
1768                               Environment env,
1769                               boolean oldTypesExist) {
1770            checkEntity(true, model, env, NAME, 0, null);
1771            checkNonEntity(true, model, env, NAME2, 1);
1772            checkNonEntity(true, model, env, NAME3, 0);
1773            checkVersions(model, NAME, 0);
1774            if (oldTypesExist) {
1775                checkVersions(model, NAME2, 1, NAME2, 0);
1776            } else {
1777                checkVersions(model, NAME2, 1);
1778            }
1779            checkVersions(model, NAME3, 0);
1780        }
1781
1782        @Override JavaDoc
1783        void readObjects(EntityStore store, boolean doUpdate)
1784            throws DatabaseException {
1785
1786            PrimaryIndex<Integer JavaDoc,InsertSuperclass2_Top>
1787                index = store.getPrimaryIndex
1788                    (Integer JavaDoc.class,
1789                     InsertSuperclass2_Top.class);
1790            InsertSuperclass2_Top obj = index.get(key);
1791            TestCase.assertNotNull(obj);
1792            TestCase.assertNotNull(obj.embed);
1793            TestCase.assertEquals(99, obj.key);
1794            TestCase.assertEquals(88, obj.ff);
1795            TestCase.assertEquals(123, obj.embed.f);
1796            TestCase.assertEquals(456, obj.embed.g);
1797            if (doUpdate) {
1798                index.put(obj);
1799            }
1800        }
1801
1802        @Override JavaDoc
1803        void copyRawObjects(RawStore rawStore, EntityStore newStore)
1804            throws DatabaseException {
1805
1806            PrimaryIndex<Integer JavaDoc,InsertSuperclass2_Top>
1807                index = newStore.getPrimaryIndex
1808                    (Integer JavaDoc.class,
1809                     InsertSuperclass2_Top.class);
1810            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
1811            index.put((InsertSuperclass2_Top)
1812                      newStore.getModel().convertRawObject(raw));
1813        }
1814
1815        @Override JavaDoc
1816        void readRawObjects(RawStore store,
1817                            boolean expectEvolved,
1818                            boolean expectUpdated)
1819            throws DatabaseException {
1820
1821            RawType embedType = store.getModel().getRawType(NAME2);
1822            RawObject embedSuper = null;
1823            if (expectEvolved) {
1824                RawType embedSuperType = store.getModel().getRawType(NAME3);
1825                Map JavaDoc<String JavaDoc,Object JavaDoc> values =
1826                    expectUpdated ? makeValues("g", 456) : makeValues();
1827                embedSuper = new RawObject(embedSuperType, values, null);
1828            }
1829            RawObject embed =
1830                new RawObject(embedType, makeValues("f", 123), embedSuper);
1831            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1832            checkRawFields(obj, "key", 99, "ff", 88, "embed", embed);
1833        }
1834    }
1835
1836    @Entity(version=1)
1837    static class DisallowNonKeyField_PrimitiveToObject
1838        extends EvolveCase {
1839
1840        private static final String JavaDoc NAME =
1841            DisallowNonKeyField_PrimitiveToObject.class.getName();
1842
1843        @PrimaryKey
1844        int key = 99;
1845
1846        String JavaDoc ff;
1847
1848        @Override JavaDoc
1849        public String JavaDoc getStoreOpenException() {
1850            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";
1851        }
1852
1853        @Override JavaDoc
1854        void checkUnevolvedModel(EntityModel model, Environment env) {
1855            checkEntity(true, model, env, NAME, 0, null);
1856            checkVersions(model, NAME, 0);
1857        }
1858
1859        @Override JavaDoc
1860        void readRawObjects(RawStore store,
1861                            boolean expectEvolved,
1862                            boolean expectUpdated)
1863            throws DatabaseException {
1864
1865            if (expectEvolved) {
1866                TestCase.fail();
1867            }
1868            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1869            checkRawFields(obj, "key", 99, "ff", 88);
1870        }
1871    }
1872
1873    @Entity(version=1)
1874    static class DisallowNonKeyField_ObjectToPrimitive
1875        extends EvolveCase {
1876
1877        private static final String JavaDoc NAME =
1878            DisallowNonKeyField_ObjectToPrimitive.class.getName();
1879
1880        @PrimaryKey
1881        int key = 99;
1882
1883        int ff;
1884
1885        @Override JavaDoc
1886        public String JavaDoc getStoreOpenException() {
1887            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";
1888        }
1889
1890        @Override JavaDoc
1891        void checkUnevolvedModel(EntityModel model, Environment env) {
1892            checkEntity(true, model, env, NAME, 0, null);
1893            checkVersions(model, NAME, 0);
1894        }
1895
1896        @Override JavaDoc
1897        void readRawObjects(RawStore store,
1898                            boolean expectEvolved,
1899                            boolean expectUpdated)
1900            throws DatabaseException {
1901
1902            if (expectEvolved) {
1903                TestCase.fail();
1904            }
1905            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1906            checkRawFields(obj, "key", 99, "ff", "88");
1907        }
1908    }
1909
1910    @Persistent
1911    static class MyType {
1912
1913        @Override JavaDoc
1914        public boolean equals(Object JavaDoc o) {
1915            return o instanceof MyType;
1916        }
1917    }
1918
1919    @Persistent
1920    static class MySubtype extends MyType {
1921
1922        @Override JavaDoc
1923        public boolean equals(Object JavaDoc o) {
1924            return o instanceof MySubtype;
1925        }
1926    }
1927
1928    @Entity(version=1)
1929    static class DisallowNonKeyField_ObjectToSubtype
1930        extends EvolveCase {
1931
1932        private static final String JavaDoc NAME =
1933            DisallowNonKeyField_ObjectToSubtype.class.getName();
1934
1935        @PrimaryKey
1936        int key = 99;
1937
1938        MySubtype ff;
1939
1940        @Override JavaDoc
1941        public String JavaDoc getStoreOpenException() {
1942            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";
1943        }
1944
1945        @Override JavaDoc
1946        void checkUnevolvedModel(EntityModel model, Environment env) {
1947            checkEntity(true, model, env, NAME, 0, null);
1948            checkVersions(model, NAME, 0);
1949        }
1950
1951        @Override JavaDoc
1952        void readRawObjects(RawStore store,
1953                            boolean expectEvolved,
1954                            boolean expectUpdated)
1955            throws DatabaseException {
1956
1957            if (expectEvolved) {
1958                TestCase.fail();
1959            }
1960            RawType embedType = store.getModel().getRawType
1961                (MyType.class.getName());
1962            RawObject embed = new RawObject(embedType, makeValues(), null);
1963
1964            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1965            checkRawFields(obj, "key", 99, "ff", embed);
1966        }
1967    }
1968
1969    @Entity(version=1)
1970    static class DisallowNonKeyField_ObjectToUnrelatedSimple
1971        extends EvolveCase {
1972
1973        private static final String JavaDoc NAME =
1974            DisallowNonKeyField_ObjectToUnrelatedSimple.class.getName();
1975
1976        @PrimaryKey
1977        int key = 99;
1978
1979        String JavaDoc ff;
1980
1981        @Override JavaDoc
1982        public String JavaDoc getStoreOpenException() {
1983            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";
1984        }
1985
1986        @Override JavaDoc
1987        void checkUnevolvedModel(EntityModel model, Environment env) {
1988            checkEntity(true, model, env, NAME, 0, null);
1989            checkVersions(model, NAME, 0);
1990        }
1991
1992        @Override JavaDoc
1993        void readRawObjects(RawStore store,
1994                            boolean expectEvolved,
1995                            boolean expectUpdated)
1996            throws DatabaseException {
1997
1998            if (expectEvolved) {
1999                TestCase.fail();
2000            }
2001            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2002            checkRawFields(obj, "key", 99, "ff", 88);
2003        }
2004    }
2005
2006    @Entity(version=1)
2007    static class DisallowNonKeyField_ObjectToUnrelatedOther
2008        extends EvolveCase {
2009
2010        private static final String JavaDoc NAME =
2011            DisallowNonKeyField_ObjectToUnrelatedOther.class.getName();
2012
2013        @PrimaryKey
2014        int key = 99;
2015
2016        MyType ff;
2017
2018        @Override JavaDoc
2019        public String JavaDoc getStoreOpenException() {
2020            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";
2021        }
2022
2023        @Override JavaDoc
2024        void checkUnevolvedModel(EntityModel model, Environment env) {
2025            checkEntity(true, model, env, NAME, 0, null);
2026            checkVersions(model, NAME, 0);
2027        }
2028
2029        @Override JavaDoc
2030        void readRawObjects(RawStore store,
2031                            boolean expectEvolved,
2032                            boolean expectUpdated)
2033            throws DatabaseException {
2034
2035            if (expectEvolved) {
2036                TestCase.fail();
2037            }
2038            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2039            checkRawFields(obj, "key", 99, "ff", 88);
2040        }
2041    }
2042
2043    @Entity(version=1)
2044    static class DisallowNonKeyField_byte2boolean
2045        extends EvolveCase {
2046
2047        private static final String JavaDoc NAME =
2048            DisallowNonKeyField_byte2boolean.class.getName();
2049
2050        @PrimaryKey
2051        int key = 99;
2052
2053        boolean ff;
2054
2055        @Override JavaDoc
2056        public String JavaDoc getStoreOpenException() {
2057            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";
2058        }
2059
2060        @Override JavaDoc
2061        void checkUnevolvedModel(EntityModel model, Environment env) {
2062            checkEntity(true, model, env, NAME, 0, null);
2063            checkVersions(model, NAME, 0);
2064        }
2065
2066        @Override JavaDoc
2067        void readRawObjects(RawStore store,
2068                            boolean expectEvolved,
2069                            boolean expectUpdated)
2070            throws DatabaseException {
2071
2072            if (expectEvolved) {
2073                TestCase.fail();
2074            }
2075            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2076            checkRawFields(obj, "key", 99, "ff", (byte) 88);
2077        }
2078    }
2079
2080    @Entity(version=1)
2081    static class DisallowNonKeyField_short2byte
2082        extends EvolveCase {
2083
2084        private static final String JavaDoc NAME =
2085            DisallowNonKeyField_short2byte.class.getName();
2086
2087        @PrimaryKey
2088        int key = 99;
2089
2090        byte ff;
2091
2092        @Override JavaDoc
2093        public String JavaDoc getStoreOpenException() {
2094            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";
2095        }
2096
2097        @Override JavaDoc
2098        void checkUnevolvedModel(EntityModel model, Environment env) {
2099            checkEntity(true, model, env, NAME, 0, null);
2100            checkVersions(model, NAME, 0);
2101        }
2102
2103        @Override JavaDoc
2104        void readRawObjects(RawStore store,
2105                            boolean expectEvolved,
2106                            boolean expectUpdated)
2107            throws DatabaseException {
2108
2109            if (expectEvolved) {
2110                TestCase.fail();
2111            }
2112            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2113            checkRawFields(obj, "key", 99, "ff", (short) 88);
2114        }
2115    }
2116
2117    @Entity(version=1)
2118    static class DisallowNonKeyField_int2short
2119        extends EvolveCase {
2120
2121        private static final String JavaDoc NAME =
2122            DisallowNonKeyField_int2short.class.getName();
2123
2124        @PrimaryKey
2125        int key = 99;
2126
2127        short ff;
2128
2129        @Override JavaDoc
2130        public String JavaDoc getStoreOpenException() {
2131            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";
2132        }
2133
2134        @Override JavaDoc
2135        void checkUnevolvedModel(EntityModel model, Environment env) {
2136            checkEntity(true, model, env, NAME, 0, null);
2137            checkVersions(model, NAME, 0);
2138        }
2139
2140        @Override JavaDoc
2141        void readRawObjects(RawStore store,
2142                            boolean expectEvolved,
2143                            boolean expectUpdated)
2144            throws DatabaseException {
2145
2146            if (expectEvolved) {
2147                TestCase.fail();
2148            }
2149            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2150            checkRawFields(obj, "key", 99, "ff", (int) 88);
2151        }
2152    }
2153
2154    @Entity(version=1)
2155    static class DisallowNonKeyField_long2int
2156        extends EvolveCase {
2157
2158        private static final String JavaDoc NAME =
2159            DisallowNonKeyField_long2int.class.getName();
2160
2161        @PrimaryKey
2162        int key = 99;
2163
2164        int ff;
2165
2166        @Override JavaDoc
2167        public String JavaDoc getStoreOpenException() {
2168            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";
2169        }
2170
2171        @Override JavaDoc
2172        void checkUnevolvedModel(EntityModel model, Environment env) {
2173            checkEntity(true, model, env, NAME, 0, null);
2174            checkVersions(model, NAME, 0);
2175        }
2176
2177        @Override JavaDoc
2178        void readRawObjects(RawStore store,
2179                            boolean expectEvolved,
2180                            boolean expectUpdated)
2181            throws DatabaseException {
2182
2183            if (expectEvolved) {
2184                TestCase.fail();
2185            }
2186            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2187            checkRawFields(obj, "key", 99, "ff", (long) 88);
2188        }
2189    }
2190
2191    @Entity(version=1)
2192    static class DisallowNonKeyField_float2long
2193        extends EvolveCase {
2194
2195        private static final String JavaDoc NAME =
2196            DisallowNonKeyField_float2long.class.getName();
2197
2198        @PrimaryKey
2199        int key = 99;
2200
2201        long ff;
2202
2203        @Override JavaDoc
2204        public String JavaDoc getStoreOpenException() {
2205            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";
2206        }
2207
2208        @Override JavaDoc
2209        void checkUnevolvedModel(EntityModel model, Environment env) {
2210            checkEntity(true, model, env, NAME, 0, null);
2211            checkVersions(model, NAME, 0);
2212        }
2213
2214        @Override JavaDoc
2215        void readRawObjects(RawStore store,
2216                            boolean expectEvolved,
2217                            boolean expectUpdated)
2218            throws DatabaseException {
2219
2220            if (expectEvolved) {
2221                TestCase.fail();
2222            }
2223            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2224            checkRawFields(obj, "key", 99, "ff", (float) 88);
2225        }
2226    }
2227
2228    @Entity(version=1)
2229    static class DisallowNonKeyField_double2float
2230        extends EvolveCase {
2231
2232        private static final String JavaDoc NAME =
2233            DisallowNonKeyField_double2float.class.getName();
2234
2235        @PrimaryKey
2236        int key = 99;
2237
2238        float ff;
2239
2240        @Override JavaDoc
2241        public String JavaDoc getStoreOpenException() {
2242            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";
2243        }
2244
2245        @Override JavaDoc
2246        void checkUnevolvedModel(EntityModel model, Environment env) {
2247            checkEntity(true, model, env, NAME, 0, null);
2248            checkVersions(model, NAME, 0);
2249        }
2250
2251        @Override JavaDoc
2252        void readRawObjects(RawStore store,
2253                            boolean expectEvolved,
2254                            boolean expectUpdated)
2255            throws DatabaseException {
2256
2257            if (expectEvolved) {
2258                TestCase.fail();
2259            }
2260            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2261            checkRawFields(obj, "key", 99, "ff", (double) 88);
2262        }
2263    }
2264
2265    @Entity(version=1)
2266    static class DisallowNonKeyField_Byte2byte
2267        extends EvolveCase {
2268
2269        private static final String JavaDoc NAME =
2270            DisallowNonKeyField_Byte2byte.class.getName();
2271
2272        @PrimaryKey
2273        int key = 99;
2274
2275        byte ff;
2276
2277        @Override JavaDoc
2278        public String JavaDoc getStoreOpenException() {
2279            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";
2280        }
2281
2282        @Override JavaDoc
2283        void checkUnevolvedModel(EntityModel model, Environment env) {
2284            checkEntity(true, model, env, NAME, 0, null);
2285            checkVersions(model, NAME, 0);
2286        }
2287
2288        @Override JavaDoc
2289        void readRawObjects(RawStore store,
2290                            boolean expectEvolved,
2291                            boolean expectUpdated)
2292            throws DatabaseException {
2293
2294            if (expectEvolved) {
2295                TestCase.fail();
2296            }
2297            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2298            checkRawFields(obj, "key", 99, "ff", (byte) 88);
2299        }
2300    }
2301
2302    @Entity(version=1)
2303    static class DisallowNonKeyField_Character2char
2304        extends EvolveCase {
2305
2306        private static final String JavaDoc NAME =
2307            DisallowNonKeyField_Character2char.class.getName();
2308
2309        @PrimaryKey
2310        int key = 99;
2311
2312        char ff;
2313
2314        @Override JavaDoc
2315        public String JavaDoc getStoreOpenException() {
2316            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";
2317        }
2318
2319        @Override JavaDoc
2320        void checkUnevolvedModel(EntityModel model, Environment env) {
2321            checkEntity(true, model, env, NAME, 0, null);
2322            checkVersions(model, NAME, 0);
2323        }
2324
2325        @Override JavaDoc
2326        void readRawObjects(RawStore store,
2327                            boolean expectEvolved,
2328                            boolean expectUpdated)
2329            throws DatabaseException {
2330
2331            if (expectEvolved) {
2332                TestCase.fail();
2333            }
2334            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2335            checkRawFields(obj, "key", 99, "ff", (char) 88);
2336        }
2337    }
2338
2339    @Entity(version=1)
2340    static class DisallowNonKeyField_Short2short
2341        extends EvolveCase {
2342
2343        private static final String JavaDoc NAME =
2344            DisallowNonKeyField_Short2short.class.getName();
2345
2346        @PrimaryKey
2347        int key = 99;
2348
2349        short ff;
2350
2351        @Override JavaDoc
2352        public String JavaDoc getStoreOpenException() {
2353            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";
2354        }
2355
2356        @Override JavaDoc
2357        void checkUnevolvedModel(EntityModel model, Environment env) {
2358            checkEntity(true, model, env, NAME, 0, null);
2359            checkVersions(model, NAME, 0);
2360        }
2361
2362        @Override JavaDoc
2363        void readRawObjects(RawStore store,
2364                            boolean expectEvolved,
2365                            boolean expectUpdated)
2366            throws DatabaseException {
2367
2368            if (expectEvolved) {
2369                TestCase.fail();
2370            }
2371            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2372            checkRawFields(obj, "key", 99, "ff", (short) 88);
2373        }
2374    }
2375
2376    @Entity(version=1)
2377    static class DisallowNonKeyField_Integer2int
2378        extends EvolveCase {
2379
2380        private static final String JavaDoc NAME =
2381            DisallowNonKeyField_Integer2int.class.getName();
2382
2383        @PrimaryKey
2384        int key = 99;
2385
2386        int ff;
2387
2388        @Override JavaDoc
2389        public String JavaDoc getStoreOpenException() {
2390            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";
2391        }
2392
2393        @Override JavaDoc
2394        void checkUnevolvedModel(EntityModel model, Environment env) {
2395            checkEntity(true, model, env, NAME, 0, null);
2396            checkVersions(model, NAME, 0);
2397        }
2398
2399        @Override JavaDoc
2400        void readRawObjects(RawStore store,
2401                            boolean expectEvolved,
2402                            boolean expectUpdated)
2403            throws DatabaseException {
2404
2405            if (expectEvolved) {
2406                TestCase.fail();
2407            }
2408            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2409            checkRawFields(obj, "key", 99, "ff", (int) 88);
2410        }
2411    }
2412
2413    @Entity(version=1)
2414    static class DisallowNonKeyField_Long2long
2415        extends EvolveCase {
2416
2417        private static final String JavaDoc NAME =
2418            DisallowNonKeyField_Long2long.class.getName();
2419
2420        @PrimaryKey
2421        int key = 99;
2422
2423        long ff;
2424
2425        @Override JavaDoc
2426        public String JavaDoc getStoreOpenException() {
2427            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";
2428        }
2429
2430        @Override JavaDoc
2431        void checkUnevolvedModel(EntityModel model, Environment env) {
2432            checkEntity(true, model, env, NAME, 0, null);
2433            checkVersions(model, NAME, 0);
2434        }
2435
2436        @Override JavaDoc
2437        void readRawObjects(RawStore store,
2438                            boolean expectEvolved,
2439                            boolean expectUpdated)
2440            throws DatabaseException {
2441
2442            if (expectEvolved) {
2443                TestCase.fail();
2444            }
2445            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2446            checkRawFields(obj, "key", 99, "ff", (long) 88);
2447        }
2448    }
2449
2450    @Entity(version=1)
2451    static class DisallowNonKeyField_Float2float
2452        extends EvolveCase {
2453
2454        private static final String JavaDoc NAME =
2455            DisallowNonKeyField_Float2float.class.getName();
2456
2457        @PrimaryKey
2458        int key = 99;
2459
2460        float ff;
2461
2462        @Override JavaDoc
2463        public String JavaDoc getStoreOpenException() {
2464            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";
2465        }
2466
2467        @Override JavaDoc
2468        void checkUnevolvedModel(EntityModel model, Environment env) {
2469            checkEntity(true, model, env, NAME, 0, null);
2470            checkVersions(model, NAME, 0);
2471        }
2472
2473        @Override JavaDoc
2474        void readRawObjects(RawStore store,
2475                            boolean expectEvolved,
2476                            boolean expectUpdated)
2477            throws DatabaseException {
2478
2479            if (expectEvolved) {
2480                TestCase.fail();
2481            }
2482            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2483            checkRawFields(obj, "key", 99, "ff", (float) 88);
2484        }
2485    }
2486
2487    @Entity(version=1)
2488    static class DisallowNonKeyField_Double2double
2489        extends EvolveCase {
2490
2491        private static final String JavaDoc NAME =
2492            DisallowNonKeyField_Double2double.class.getName();
2493
2494        @PrimaryKey
2495        int key = 99;
2496
2497        double ff;
2498
2499        @Override JavaDoc
2500        public String JavaDoc getStoreOpenException() {
2501            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";
2502        }
2503
2504        @Override JavaDoc
2505        void checkUnevolvedModel(EntityModel model, Environment env) {
2506            checkEntity(true, model, env, NAME, 0, null);
2507            checkVersions(model, NAME, 0);
2508        }
2509
2510        @Override JavaDoc
2511        void readRawObjects(RawStore store,
2512                            boolean expectEvolved,
2513                            boolean expectUpdated)
2514            throws DatabaseException {
2515
2516            if (expectEvolved) {
2517                TestCase.fail();
2518            }
2519            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2520            checkRawFields(obj, "key", 99, "ff", (double) 88);
2521        }
2522    }
2523
2524    @Entity(version=1)
2525    static class DisallowNonKeyField_float2BigInt
2526        extends EvolveCase {
2527
2528        private static final String JavaDoc NAME =
2529            DisallowNonKeyField_float2BigInt.class.getName();
2530
2531        @PrimaryKey
2532        int key = 99;
2533
2534        BigInteger JavaDoc ff;
2535
2536        @Override JavaDoc
2537        public String JavaDoc getStoreOpenException() {
2538            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";
2539        }
2540
2541        @Override JavaDoc
2542        void checkUnevolvedModel(EntityModel model, Environment env) {
2543            checkEntity(true, model, env, NAME, 0, null);
2544            checkVersions(model, NAME, 0);
2545        }
2546
2547        @Override JavaDoc
2548        void readRawObjects(RawStore store,
2549                            boolean expectEvolved,
2550                            boolean expectUpdated)
2551            throws DatabaseException {
2552
2553            if (expectEvolved) {
2554                TestCase.fail();
2555            }
2556            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2557            checkRawFields(obj, "key", 99, "ff", (float) 88);
2558        }
2559    }
2560
2561    @Entity(version=1)
2562    static class DisallowNonKeyField_BigInt2long
2563        extends EvolveCase {
2564
2565        private static final String JavaDoc NAME =
2566            DisallowNonKeyField_BigInt2long.class.getName();
2567
2568        @PrimaryKey
2569        int key = 99;
2570
2571        long ff;
2572
2573        @Override JavaDoc
2574        public String JavaDoc getStoreOpenException() {
2575            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";
2576        }
2577
2578        @Override JavaDoc
2579        void checkUnevolvedModel(EntityModel model, Environment env) {
2580            checkEntity(true, model, env, NAME, 0, null);
2581            checkVersions(model, NAME, 0);
2582        }
2583
2584        @Override JavaDoc
2585        void readRawObjects(RawStore store,
2586                            boolean expectEvolved,
2587                            boolean expectUpdated)
2588            throws DatabaseException {
2589
2590            if (expectEvolved) {
2591                TestCase.fail();
2592            }
2593            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2594            checkRawFields(obj, "key", 99, "ff", BigInteger.valueOf(88));
2595        }
2596    }
2597
2598    @Entity(version=1)
2599    static class DisallowSecKeyField_byte2short
2600        extends EvolveCase {
2601
2602        private static final String JavaDoc NAME =
2603            DisallowSecKeyField_byte2short.class.getName();
2604
2605        @PrimaryKey
2606        int key = 99;
2607
2608        @SecondaryKey(relate=ONE_TO_ONE)
2609        short ff;
2610
2611        @Override JavaDoc
2612        public String JavaDoc getStoreOpenException() {
2613            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";
2614        }
2615
2616        @Override JavaDoc
2617        void checkUnevolvedModel(EntityModel model, Environment env) {
2618            checkEntity(true, model, env, NAME, 0, "ff");
2619            checkVersions(model, NAME, 0);
2620        }
2621
2622        @Override JavaDoc
2623        void readRawObjects(RawStore store,
2624                            boolean expectEvolved,
2625                            boolean expectUpdated)
2626            throws DatabaseException {
2627
2628            if (expectEvolved) {
2629                TestCase.fail();
2630            }
2631            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2632            checkRawFields(obj, "key", 99, "ff", (byte) 88);
2633        }
2634    }
2635
2636    @Entity(version=1)
2637    static class DisallowSecKeyField_char2int
2638        extends EvolveCase {
2639
2640        private static final String JavaDoc NAME =
2641            DisallowSecKeyField_char2int.class.getName();
2642
2643        @PrimaryKey
2644        int key = 99;
2645
2646        @SecondaryKey(relate=ONE_TO_ONE)
2647        int ff;
2648
2649        @Override JavaDoc
2650        public String JavaDoc getStoreOpenException() {
2651            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";
2652        }
2653
2654        @Override JavaDoc
2655        void checkUnevolvedModel(EntityModel model, Environment env) {
2656            checkEntity(true, model, env, NAME, 0, "ff");
2657            checkVersions(model, NAME, 0);
2658        }
2659
2660        @Override JavaDoc
2661        void readRawObjects(RawStore store,
2662                            boolean expectEvolved,
2663                            boolean expectUpdated)
2664            throws DatabaseException {
2665
2666            if (expectEvolved) {
2667                TestCase.fail();
2668            }
2669            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2670            checkRawFields(obj, "key", 99, "ff", (char) 88);
2671        }
2672    }
2673
2674    @Entity(version=1)
2675    static class DisallowSecKeyField_short2int
2676        extends EvolveCase {
2677
2678        private static final String JavaDoc NAME =
2679            DisallowSecKeyField_short2int.class.getName();
2680
2681        @PrimaryKey
2682        int key = 99;
2683
2684        @SecondaryKey(relate=ONE_TO_ONE)
2685        int ff;
2686
2687        @Override JavaDoc
2688        public String JavaDoc getStoreOpenException() {
2689            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";
2690        }
2691
2692        @Override JavaDoc
2693        void checkUnevolvedModel(EntityModel model, Environment env) {
2694            checkEntity(true, model, env, NAME, 0, "ff");
2695            checkVersions(model, NAME, 0);
2696        }
2697
2698        @Override JavaDoc
2699        void readRawObjects(RawStore store,
2700                            boolean expectEvolved,
2701                            boolean expectUpdated)
2702            throws DatabaseException {
2703
2704            if (expectEvolved) {
2705                TestCase.fail();
2706            }
2707            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2708            checkRawFields(obj, "key", 99, "ff", (short) 88);
2709        }
2710    }
2711
2712    @Entity(version=1)
2713    static class DisallowSecKeyField_int2long
2714        extends EvolveCase {
2715
2716        private static final String JavaDoc NAME =
2717            DisallowSecKeyField_int2long.class.getName();
2718
2719        @PrimaryKey
2720        int key = 99;
2721
2722        @SecondaryKey(relate=ONE_TO_ONE)
2723        long ff;
2724
2725        @Override JavaDoc
2726        public String JavaDoc getStoreOpenException() {
2727            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";
2728        }
2729
2730        @Override JavaDoc
2731        void checkUnevolvedModel(EntityModel model, Environment env) {
2732            checkEntity(true, model, env, NAME, 0, "ff");
2733            checkVersions(model, NAME, 0);
2734        }
2735
2736        @Override JavaDoc
2737        void readRawObjects(RawStore store,
2738                            boolean expectEvolved,
2739                            boolean expectUpdated)
2740            throws DatabaseException {
2741
2742            if (expectEvolved) {
2743                TestCase.fail();
2744            }
2745            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2746            checkRawFields(obj, "key", 99, "ff", (int) 88);
2747        }
2748    }
2749
2750    @Entity(version=1)
2751    static class DisallowSecKeyField_long2float
2752        extends EvolveCase {
2753
2754        private static final String JavaDoc NAME =
2755            DisallowSecKeyField_long2float.class.getName();
2756
2757        @PrimaryKey
2758        int key = 99;
2759
2760        @SecondaryKey(relate=ONE_TO_ONE)
2761        float ff;
2762
2763        @Override JavaDoc
2764        public String JavaDoc getStoreOpenException() {
2765            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";
2766        }
2767
2768        @Override JavaDoc
2769        void checkUnevolvedModel(EntityModel model, Environment env) {
2770            checkEntity(true, model, env, NAME, 0, "ff");
2771            checkVersions(model, NAME, 0);
2772        }
2773
2774        @Override JavaDoc
2775        void readRawObjects(RawStore store,
2776                            boolean expectEvolved,
2777                            boolean expectUpdated)
2778            throws DatabaseException {
2779
2780            if (expectEvolved) {
2781                TestCase.fail();
2782            }
2783            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2784            checkRawFields(obj, "key", 99, "ff", (long) 88);
2785        }
2786    }
2787
2788    @Entity(version=1)
2789    static class DisallowSecKeyField_float2double
2790        extends EvolveCase {
2791
2792        private static final String JavaDoc NAME =
2793            DisallowSecKeyField_float2double.class.getName();
2794
2795        @PrimaryKey
2796        int key = 99;
2797
2798        @SecondaryKey(relate=ONE_TO_ONE)
2799        double ff;
2800
2801        @Override JavaDoc
2802        public String JavaDoc getStoreOpenException() {
2803            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";
2804        }
2805
2806        @Override JavaDoc
2807        void checkUnevolvedModel(EntityModel model, Environment env) {
2808            checkEntity(true, model, env, NAME, 0, "ff");
2809            checkVersions(model, NAME, 0);
2810        }
2811
2812        @Override JavaDoc
2813        void readRawObjects(RawStore store,
2814                            boolean expectEvolved,
2815                            boolean expectUpdated)
2816            throws DatabaseException {
2817
2818            if (expectEvolved) {
2819                TestCase.fail();
2820            }
2821            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2822            checkRawFields(obj, "key", 99, "ff", (float) 88);
2823        }
2824    }
2825
2826    @Entity(version=1)
2827    static class DisallowSecKeyField_Byte2short2
2828        extends EvolveCase {
2829
2830        private static final String JavaDoc NAME =
2831            DisallowSecKeyField_Byte2short2.class.getName();
2832
2833        @PrimaryKey
2834        int key = 99;
2835
2836        @SecondaryKey(relate=ONE_TO_ONE)
2837        short ff;
2838
2839        @Override JavaDoc
2840        public String JavaDoc getStoreOpenException() {
2841            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";
2842        }
2843
2844        @Override JavaDoc
2845        void checkUnevolvedModel(EntityModel model, Environment env) {
2846            checkEntity(true, model, env, NAME, 0, "ff");
2847            checkVersions(model, NAME, 0);
2848        }
2849
2850        @Override JavaDoc
2851        void readRawObjects(RawStore store,
2852                            boolean expectEvolved,
2853                            boolean expectUpdated)
2854            throws DatabaseException {
2855
2856            if (expectEvolved) {
2857                TestCase.fail();
2858            }
2859            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2860            checkRawFields(obj, "key", 99, "ff", (byte) 88);
2861        }
2862    }
2863
2864    @Entity(version=1)
2865    static class DisallowSecKeyField_Character2int
2866        extends EvolveCase {
2867
2868        private static final String JavaDoc NAME =
2869            DisallowSecKeyField_Character2int.class.getName();
2870
2871        @PrimaryKey
2872        int key = 99;
2873
2874        @SecondaryKey(relate=ONE_TO_ONE)
2875        int ff;
2876
2877        @Override JavaDoc
2878        public String JavaDoc getStoreOpenException() {
2879            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";
2880        }
2881
2882        @Override JavaDoc
2883        void checkUnevolvedModel(EntityModel model, Environment env) {
2884            checkEntity(true, model, env, NAME, 0, "ff");
2885            checkVersions(model, NAME, 0);
2886        }
2887
2888        @Override JavaDoc
2889        void readRawObjects(RawStore store,
2890                            boolean expectEvolved,
2891                            boolean expectUpdated)
2892            throws DatabaseException {
2893
2894            if (expectEvolved) {
2895                TestCase.fail();
2896            }
2897            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2898            checkRawFields(obj, "key", 99, "ff", (char) 88);
2899        }
2900    }
2901
2902    @Entity(version=1)
2903    static class DisallowSecKeyField_Short2int2
2904        extends EvolveCase {
2905
2906        private static final String JavaDoc NAME =
2907            DisallowSecKeyField_Short2int2.class.getName();
2908
2909        @PrimaryKey
2910        int key = 99;
2911
2912        @SecondaryKey(relate=ONE_TO_ONE)
2913        int ff;
2914
2915        @Override JavaDoc
2916        public String JavaDoc getStoreOpenException() {
2917            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";
2918        }
2919
2920        @Override JavaDoc
2921        void checkUnevolvedModel(EntityModel model, Environment env) {
2922            checkEntity(true, model, env, NAME, 0, "ff");
2923            checkVersions(model, NAME, 0);
2924        }
2925
2926        @Override JavaDoc
2927        void readRawObjects(RawStore store,
2928                            boolean expectEvolved,
2929                            boolean expectUpdated)
2930            throws DatabaseException {
2931
2932            if (expectEvolved) {
2933                TestCase.fail();
2934            }
2935            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2936            checkRawFields(obj, "key", 99, "ff", (short) 88);
2937        }
2938    }
2939
2940    @Entity(version=1)
2941    static class DisallowSecKeyField_Integer2long
2942        extends EvolveCase {
2943
2944        private static final String JavaDoc NAME =
2945            DisallowSecKeyField_Integer2long.class.getName();
2946
2947        @PrimaryKey
2948        int key = 99;
2949
2950        @SecondaryKey(relate=ONE_TO_ONE)
2951        long ff;
2952
2953        @Override JavaDoc
2954        public String JavaDoc getStoreOpenException() {
2955            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";
2956        }
2957
2958        @Override JavaDoc
2959        void checkUnevolvedModel(EntityModel model, Environment env) {
2960            checkEntity(true, model, env, NAME, 0, "ff");
2961            checkVersions(model, NAME, 0);
2962        }
2963
2964        @Override JavaDoc
2965        void readRawObjects(RawStore store,
2966                            boolean expectEvolved,
2967                            boolean expectUpdated)
2968            throws DatabaseException {
2969
2970            if (expectEvolved) {
2971                TestCase.fail();
2972            }
2973            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2974            checkRawFields(obj, "key", 99, "ff", (int) 88);
2975        }
2976    }
2977
2978    @Entity(version=1)
2979    static class DisallowSecKeyField_Long2float2
2980        extends EvolveCase {
2981
2982        private static final String JavaDoc NAME =
2983            DisallowSecKeyField_Long2float2.class.getName();
2984
2985        @PrimaryKey
2986        int key = 99;
2987
2988        @SecondaryKey(relate=ONE_TO_ONE)
2989        float ff;
2990
2991        @Override JavaDoc
2992        public String JavaDoc getStoreOpenException() {
2993            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";
2994        }
2995
2996        @Override JavaDoc
2997        void checkUnevolvedModel(EntityModel model, Environment env) {
2998            checkEntity(true, model, env, NAME, 0, "ff");
2999            checkVersions(model, NAME, 0);
3000        }
3001
3002        @Override JavaDoc
3003        void readRawObjects(RawStore store,
3004                            boolean expectEvolved,
3005                            boolean expectUpdated)
3006            throws DatabaseException {
3007
3008            if (expectEvolved) {
3009                TestCase.fail();
3010            }
3011            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
3012            checkRawFields(obj, "key", 99, "ff", (long) 88);
3013        }
3014    }
3015
3016    @Entity(version=1)
3017    static class DisallowSecKeyField_Float2double2
3018        extends EvolveCase {
3019
3020        private static final String JavaDoc NAME =
3021            DisallowSecKeyField_Float2double2.class.getName();
3022
3023        @PrimaryKey
3024        int key = 99;
3025
3026        @SecondaryKey(relate=ONE_TO_ONE)
3027        double ff;
3028
3029        @Override JavaDoc
3030        public String JavaDoc getStoreOpenException() {
3031            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";
3032        }
3033
3034        @Override JavaDoc
3035        void checkUnevolvedModel(EntityModel model, Environment env) {
3036            checkEntity(true, model, env, NAME, 0, "ff");
3037            checkVersions(model, NAME, 0);
3038        }
3039
3040        @Override JavaDoc
3041        void readRawObjects(RawStore store,
3042                            boolean expectEvolved,
3043                            boolean expectUpdated)
3044            throws DatabaseException {
3045
3046            if (expectEvolved) {
3047                TestCase.fail();
3048            }
3049            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
3050            checkRawFields(obj, "key", 99, "ff", (float) 88);
3051        }
3052    }
3053
3054    @Entity(version=1)
3055    static class DisallowSecKeyField_int2BigInt
3056        extends EvolveCase {
3057
3058        private static final String JavaDoc NAME =
3059            DisallowSecKeyField_int2BigInt.class.getName();
3060
3061        @PrimaryKey
3062        int key = 99;
3063
3064        @SecondaryKey(relate=ONE_TO_ONE)
3065        BigInteger JavaDoc ff;
3066
3067        @Override JavaDoc
3068        public String JavaDoc getStoreOpenException() {
3069            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";
3070        }
3071
3072        @Override JavaDoc
3073        void checkUnevolvedModel(EntityModel model, Environment env) {
3074            checkEntity(true, model, env, NAME, 0, "ff");
3075            checkVersions(model, NAME, 0);
3076        }
3077
3078        @Override JavaDoc
3079        void readRawObjects(RawStore store,
3080                            boolean expectEvolved,
3081                            boolean expectUpdated)
3082            throws DatabaseException {
3083
3084            if (expectEvolved) {
3085                TestCase.fail();
3086            }
3087            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
3088            checkRawFields(obj, "key", 99, "ff", 88);
3089        }
3090    }
3091
3092    // ---
3093

3094    @Entity(version=1)
3095    static class DisallowPriKeyField_byte2short
3096        extends EvolveCase {
3097
3098        private static final String JavaDoc NAME =
3099            DisallowPriKeyField_byte2short.class.getName();
3100
3101        @PrimaryKey
3102        short key;
3103
3104        @Override JavaDoc
3105        public String JavaDoc getStoreOpenException() {
3106            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";
3107        }
3108
3109        @Override JavaDoc
3110        void checkUnevolvedModel(EntityModel model, Environment env) {
3111            checkEntity(true, model, env, NAME, 0, null);
3112            checkVersions(model, NAME, 0);
3113        }
3114
3115        @Override JavaDoc
3116        void readRawObjects(RawStore store,
3117                            boolean expectEvolved,
3118                            boolean expectUpdated)
3119            throws DatabaseException {
3120
3121            if (expectEvolved) {
3122                TestCase.fail();
3123            }
3124            RawObject obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3125            checkRawFields(obj, "key", (byte) 99);
3126        }
3127    }
3128
3129    @Entity(version=1)
3130    static class DisallowPriKeyField_char2int
3131        extends EvolveCase {
3132
3133        private static final String JavaDoc NAME =
3134            DisallowPriKeyField_char2int.class.getName();
3135
3136        @PrimaryKey
3137        int key;
3138
3139        @Override JavaDoc
3140        public String JavaDoc getStoreOpenException() {
3141            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";
3142        }
3143
3144        @Override JavaDoc
3145        void checkUnevolvedModel(EntityModel model, Environment env) {
3146            checkEntity(true, model, env, NAME, 0, null);
3147            checkVersions(model, NAME, 0);
3148        }
3149
3150        @Override JavaDoc
3151        void readRawObjects(RawStore store,
3152                            boolean expectEvolved,
3153                            boolean expectUpdated)
3154            throws DatabaseException {
3155
3156            if (expectEvolved) {
3157                TestCase.fail();
3158            }
3159            RawObject obj = readRaw(store, (char) 99, NAME, 0, CASECLS, 0);
3160            checkRawFields(obj, "key", (char) 99);
3161        }
3162    }
3163
3164    @Entity(version=1)
3165    static class DisallowPriKeyField_short2int
3166        extends EvolveCase {
3167
3168        private static final String JavaDoc NAME =
3169            DisallowPriKeyField_short2int.class.getName();
3170
3171        @PrimaryKey
3172        int key;
3173
3174        @Override JavaDoc
3175        public String JavaDoc getStoreOpenException() {
3176            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";
3177        }
3178
3179        @Override JavaDoc
3180        void checkUnevolvedModel(EntityModel model, Environment env) {
3181            checkEntity(true, model, env, NAME, 0, null);
3182            checkVersions(model, NAME, 0);
3183        }
3184
3185        @Override JavaDoc
3186        void readRawObjects(RawStore store,
3187                            boolean expectEvolved,
3188                            boolean expectUpdated)
3189            throws DatabaseException {
3190
3191            if (expectEvolved) {
3192                TestCase.fail();
3193            }
3194            RawObject obj = readRaw(store, (short) 99, NAME, 0, CASECLS, 0);
3195            checkRawFields(obj, "key", (short) 99);
3196        }
3197    }
3198
3199    @Entity(version=1)
3200    static class DisallowPriKeyField_int2long
3201        extends EvolveCase {
3202
3203        private static final String JavaDoc NAME =
3204            DisallowPriKeyField_int2long.class.getName();
3205
3206        @PrimaryKey
3207        long key;
3208
3209        @Override JavaDoc
3210        public String JavaDoc getStoreOpenException() {
3211            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";
3212        }
3213
3214        @Override JavaDoc
3215        void checkUnevolvedModel(EntityModel model, Environment env) {
3216            checkEntity(true, model, env, NAME, 0, null);
3217            checkVersions(model, NAME, 0);
3218        }
3219
3220        @Override JavaDoc
3221        void readRawObjects(RawStore store,
3222                            boolean expectEvolved,
3223                            boolean expectUpdated)
3224            throws DatabaseException {
3225
3226            if (expectEvolved) {
3227                TestCase.fail();
3228            }
3229            RawObject obj = readRaw(store, (int) 99, NAME, 0, CASECLS, 0);
3230            checkRawFields(obj, "key", (int) 99);
3231        }
3232    }
3233
3234    @Entity(version=1)
3235    static class DisallowPriKeyField_long2float
3236        extends EvolveCase {
3237
3238        private static final String JavaDoc NAME =
3239            DisallowPriKeyField_long2float.class.getName();
3240
3241        @PrimaryKey
3242        float key;
3243
3244        @Override JavaDoc
3245        public String JavaDoc getStoreOpenException() {
3246            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";
3247        }
3248
3249        @Override JavaDoc
3250        void checkUnevolvedModel(EntityModel model, Environment env) {
3251            checkEntity(true, model, env, NAME, 0, null);
3252            checkVersions(model, NAME, 0);
3253        }
3254
3255        @Override JavaDoc
3256        void readRawObjects(RawStore store,
3257                            boolean expectEvolved,
3258                            boolean expectUpdated)
3259            throws DatabaseException {
3260
3261            if (expectEvolved) {
3262                TestCase.fail();
3263            }
3264            RawObject obj = readRaw(store, (long) 99, NAME, 0, CASECLS, 0);
3265            checkRawFields(obj, "key", (long) 99);
3266        }
3267    }
3268
3269    @Entity(version=1)
3270    static class DisallowPriKeyField_float2double
3271        extends EvolveCase {
3272
3273        private static final String JavaDoc NAME =
3274            DisallowPriKeyField_float2double.class.getName();
3275
3276        @PrimaryKey
3277        double key;
3278
3279        @Override JavaDoc
3280        public String JavaDoc getStoreOpenException() {
3281            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";
3282        }
3283
3284        @Override JavaDoc
3285        void checkUnevolvedModel(EntityModel model, Environment env) {
3286            checkEntity(true, model, env, NAME, 0, null);
3287            checkVersions(model, NAME, 0);
3288        }
3289
3290        @Override JavaDoc
3291        void readRawObjects(RawStore store,
3292                            boolean expectEvolved,
3293                            boolean expectUpdated)
3294            throws DatabaseException {
3295
3296            if (expectEvolved) {
3297                TestCase.fail();
3298            }
3299            RawObject obj = readRaw(store, (float) 99, NAME, 0, CASECLS, 0);
3300            checkRawFields(obj, "key", (float) 99);
3301        }
3302    }
3303
3304    @Entity(version=1)
3305    static class DisallowPriKeyField_Byte2short2
3306        extends EvolveCase {
3307
3308        private static final String JavaDoc NAME =
3309            DisallowPriKeyField_Byte2short2.class.getName();
3310
3311        @PrimaryKey
3312        short key;
3313
3314        @Override JavaDoc
3315        public String JavaDoc getStoreOpenException() {
3316            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";
3317        }
3318
3319        @Override JavaDoc
3320        void checkUnevolvedModel(EntityModel model, Environment env) {
3321            checkEntity(true, model, env, NAME, 0, null);
3322            checkVersions(model, NAME, 0);
3323        }
3324
3325        @Override JavaDoc
3326        void readRawObjects(RawStore store,
3327                            boolean expectEvolved,
3328                            boolean expectUpdated)
3329            throws DatabaseException {
3330
3331            if (expectEvolved) {
3332                TestCase.fail();
3333            }
3334            RawObject obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3335            checkRawFields(obj, "key", (byte) 99);
3336        }
3337    }
3338
3339    @Entity(version=1)
3340    static class DisallowPriKeyField_Character2int
3341        extends EvolveCase {
3342
3343        private static final String JavaDoc NAME =
3344            DisallowPriKeyField_Character2int.class.getName();
3345
3346        @PrimaryKey
3347        int key;
3348
3349        @Override JavaDoc
3350        public String JavaDoc getStoreOpenException() {
3351            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";
3352        }
3353
3354        @Override JavaDoc
3355        void checkUnevolvedModel(EntityModel model, Environment env) {
3356            checkEntity(true, model, env, NAME, 0, null);
3357            checkVersions(model, NAME, 0);
3358        }
3359
3360        @Override JavaDoc
3361        void readRawObjects(RawStore store,
3362                            boolean expectEvolved,
3363                            boolean expectUpdated)
3364            throws DatabaseException {
3365
3366            if (expectEvolved) {
3367                TestCase.fail();
3368            }
3369            RawObject obj = readRaw(store, (char) 99, NAME, 0, CASECLS, 0);
3370            checkRawFields(obj, "key", (char) 99);
3371        }
3372    }
3373
3374    @Entity(version=1)
3375    static class DisallowPriKeyField_Short2int2
3376        extends EvolveCase {
3377
3378        private static final String JavaDoc NAME =
3379            DisallowPriKeyField_Short2int2.class.getName();
3380
3381        @PrimaryKey
3382        int key;
3383
3384        @Override JavaDoc
3385        public String JavaDoc getStoreOpenException() {
3386            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";
3387        }
3388
3389        @Override JavaDoc
3390        void checkUnevolvedModel(EntityModel model, Environment env) {
3391            checkEntity(true, model, env, NAME, 0, null);
3392            checkVersions(model, NAME, 0);
3393        }
3394
3395        @Override JavaDoc
3396        void readRawObjects(RawStore store,
3397                            boolean expectEvolved,
3398                            boolean expectUpdated)
3399            throws DatabaseException {
3400
3401            if (expectEvolved) {
3402                TestCase.fail();
3403            }
3404            RawObject obj = readRaw(store, (short) 99, NAME, 0, CASECLS, 0);
3405            checkRawFields(obj, "key", (short) 99);
3406        }
3407    }
3408
3409    @Entity(version=1)
3410    static class DisallowPriKeyField_Integer2long
3411        extends EvolveCase {
3412
3413        private static final String JavaDoc NAME =
3414            DisallowPriKeyField_Integer2long.class.getName();
3415
3416        @PrimaryKey
3417        long key;
3418
3419        @Override JavaDoc
3420        public String JavaDoc getStoreOpenException() {
3421            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";
3422        }
3423
3424        @Override JavaDoc
3425        void checkUnevolvedModel(EntityModel model, Environment env) {
3426            checkEntity(true, model, env, NAME, 0, null);
3427            checkVersions(model, NAME, 0);
3428        }
3429
3430        @Override JavaDoc
3431        void readRawObjects(RawStore store,
3432                            boolean expectEvolved,
3433                            boolean expectUpdated)
3434            throws DatabaseException {
3435
3436            if (expectEvolved) {
3437                TestCase.fail();
3438            }
3439            RawObject obj = readRaw(store, (int) 99, NAME, 0, CASECLS, 0);
3440            checkRawFields(obj, "key", (int) 99);
3441        }
3442    }
3443
3444    @Entity(version=1)
3445    static class DisallowPriKeyField_Long2float2
3446        extends EvolveCase {
3447
3448        private static final String JavaDoc NAME =
3449            DisallowPriKeyField_Long2float2.class.getName();
3450
3451        @PrimaryKey
3452        float key;
3453
3454        @Override JavaDoc
3455        public String JavaDoc getStoreOpenException() {
3456            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";
3457        }
3458
3459        @Override JavaDoc
3460        void checkUnevolvedModel(EntityModel model, Environment env) {
3461            checkEntity(true, model, env, NAME, 0, null);
3462            checkVersions(model, NAME, 0);
3463        }
3464
3465        @Override JavaDoc
3466        void readRawObjects(RawStore store,
3467                            boolean expectEvolved,
3468                            boolean expectUpdated)
3469            throws DatabaseException {
3470
3471            if (expectEvolved) {
3472                TestCase.fail();
3473            }
3474            RawObject obj = readRaw(store, (long) 99, NAME, 0, CASECLS, 0);
3475            checkRawFields(obj, "key", (long) 99);
3476        }
3477    }
3478
3479    @Entity(version=1)
3480    static class DisallowPriKeyField_Float2double2
3481        extends EvolveCase {
3482
3483        private static final String JavaDoc NAME =
3484            DisallowPriKeyField_Float2double2.class.getName();
3485
3486        @PrimaryKey
3487        double key;
3488
3489        @Override JavaDoc
3490        public String JavaDoc getStoreOpenException() {
3491            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";
3492        }
3493
3494        @Override JavaDoc
3495        void checkUnevolvedModel(EntityModel model, Environment env) {
3496            checkEntity(true, model, env, NAME, 0, null);
3497            checkVersions(model, NAME, 0);
3498        }
3499
3500        @Override JavaDoc
3501        void readRawObjects(RawStore store,
3502                            boolean expectEvolved,
3503                            boolean expectUpdated)
3504            throws DatabaseException {
3505
3506            if (expectEvolved) {
3507                TestCase.fail();
3508            }
3509            RawObject obj = readRaw(store, (float) 99, NAME, 0, CASECLS, 0);
3510            checkRawFields(obj, "key", (float) 99);
3511        }
3512    }
3513
3514    @Entity(version=1)
3515    static class DisallowPriKeyField_Long2BigInt
3516        extends EvolveCase {
3517
3518        private static final String JavaDoc NAME =
3519            DisallowPriKeyField_Long2BigInt.class.getName();
3520
3521        @PrimaryKey
3522        BigInteger JavaDoc key;
3523
3524        @Override JavaDoc
3525        public String JavaDoc getStoreOpenException() {
3526            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";
3527        }
3528
3529        @Override JavaDoc
3530        void checkUnevolvedModel(EntityModel model, Environment env) {
3531            checkEntity(true, model, env, NAME, 0, null);
3532            checkVersions(model, NAME, 0);
3533        }
3534
3535        @Override JavaDoc
3536        void readRawObjects(RawStore store,
3537                            boolean expectEvolved,
3538                            boolean expectUpdated)
3539            throws DatabaseException {
3540
3541            if (expectEvolved) {
3542                TestCase.fail();
3543            }
3544            RawObject obj = readRaw(store, 99L, NAME, 0, CASECLS, 0);
3545            checkRawFields(obj, "key", 99L);
3546        }
3547    }
3548
3549    @Persistent(version=1)
3550    static class DisallowCompositeKeyField_byte2short_Key {
3551
3552        @KeyField(1)
3553        int f1 = 1;
3554
3555        @KeyField(2)
3556        short f2 = 2;
3557
3558        @KeyField(3)
3559        String JavaDoc f3 = "3";
3560    }
3561
3562    @Entity
3563    static class DisallowCompositeKeyField_byte2short
3564        extends EvolveCase {
3565
3566        private static final String JavaDoc NAME =
3567            DisallowCompositeKeyField_byte2short.class.getName();
3568        private static final String JavaDoc NAME2 =
3569            DisallowCompositeKeyField_byte2short_Key.class.getName();
3570
3571        @PrimaryKey
3572        DisallowCompositeKeyField_byte2short_Key key;
3573
3574        @Override JavaDoc
3575        public String JavaDoc getStoreOpenException() {
3576            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";
3577        }
3578
3579        @Override JavaDoc
3580        void checkUnevolvedModel(EntityModel model, Environment env) {
3581            checkEntity(true, model, env, NAME, 0, null);
3582            checkNonEntity(true, model, env, NAME2, 0);
3583            checkVersions(model, NAME, 0);
3584            checkVersions(model, NAME2, 0);
3585        }
3586
3587        @Override JavaDoc
3588        void readRawObjects(RawStore store,
3589                            boolean expectEvolved,
3590                            boolean expectUpdated)
3591            throws DatabaseException {
3592
3593            if (expectEvolved) {
3594                TestCase.fail();
3595            }
3596            RawType rawKeyType = store.getModel().getRawType(NAME2);
3597            RawObject rawKey = new RawObject
3598                (rawKeyType,
3599                 makeValues("f1", (int) 1, "f2", (byte) 2, "f3", "3"),
3600                 null);
3601
3602            RawObject obj = readRaw(store, rawKey, NAME, 0, CASECLS, 0);
3603            checkRawFields(obj, "key", rawKey);
3604        }
3605    }
3606
3607    @Entity(version=1)
3608    static class AllowPriKeyField_byte2Byte
3609        extends EvolveCase {
3610
3611        private static final String JavaDoc NAME =
3612            AllowPriKeyField_byte2Byte.class.getName();
3613
3614        @PrimaryKey
3615        Byte JavaDoc key = 99;
3616
3617        @Override JavaDoc
3618        void checkEvolvedModel(EntityModel model,
3619                               Environment env,
3620                               boolean oldTypesExist) {
3621            checkEntity(true, model, env, NAME, 1, null);
3622            if (oldTypesExist) {
3623                checkVersions(model, NAME, 1, NAME, 0);
3624            } else {
3625                checkVersions(model, NAME, 1);
3626            }
3627        }
3628
3629        @Override JavaDoc
3630        void readObjects(EntityStore store, boolean doUpdate)
3631            throws DatabaseException {
3632
3633            PrimaryIndex<Byte JavaDoc,AllowPriKeyField_byte2Byte>
3634                index = store.getPrimaryIndex
3635                    (Byte JavaDoc.class,
3636                     AllowPriKeyField_byte2Byte.class);
3637            AllowPriKeyField_byte2Byte obj = index.get(key);
3638            TestCase.assertNotNull(obj);
3639            TestCase.assertEquals(Byte.valueOf((byte) 99), obj.key);
3640
3641            if (doUpdate) {
3642                index.put(obj);
3643            }
3644        }
3645
3646        @Override JavaDoc
3647        void copyRawObjects(RawStore rawStore, EntityStore newStore)
3648            throws DatabaseException {
3649
3650            PrimaryIndex<Byte JavaDoc,AllowPriKeyField_byte2Byte>
3651                index = newStore.getPrimaryIndex
3652                    (Byte JavaDoc.class,
3653                     AllowPriKeyField_byte2Byte.class);
3654            RawObject raw = rawStore.getPrimaryIndex(NAME).get((byte) 99);
3655            index.put((AllowPriKeyField_byte2Byte)
3656                      newStore.getModel().convertRawObject(raw));
3657        }
3658
3659        @Override JavaDoc
3660        void readRawObjects(RawStore store,
3661                            boolean expectEvolved,
3662                            boolean expectUpdated)
3663            throws DatabaseException {
3664
3665            RawObject obj;
3666            if (expectEvolved) {
3667                obj = readRaw(store, (byte) 99, NAME, 1, CASECLS, 0);
3668            } else {
3669                obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3670            }
3671            checkRawFields(obj, "key", (byte) 99);
3672        }
3673    }
3674
3675    @Entity(version=1)
3676    static class AllowPriKeyField_Byte2byte2
3677        extends EvolveCase {
3678
3679        private static final String JavaDoc NAME =
3680            AllowPriKeyField_Byte2byte2.class.getName();
3681
3682        @PrimaryKey
3683        byte key = 99;
3684
3685        @Override JavaDoc
3686        void checkEvolvedModel(EntityModel model,
3687                               Environment env,
3688                               boolean oldTypesExist) {
3689            checkEntity(true, model, env, NAME, 1, null);
3690            if (oldTypesExist) {
3691                checkVersions(model, NAME, 1, NAME, 0);
3692            } else {
3693                checkVersions(model, NAME, 1);
3694            }
3695        }
3696
3697        @Override JavaDoc
3698        void readObjects(EntityStore store, boolean doUpdate)
3699            throws DatabaseException {
3700
3701            PrimaryIndex<Byte JavaDoc,AllowPriKeyField_Byte2byte2>
3702                index = store.getPrimaryIndex
3703                    (Byte JavaDoc.class,
3704                     AllowPriKeyField_Byte2byte2.class);
3705            AllowPriKeyField_Byte2byte2 obj = index.get(key);
3706            TestCase.assertNotNull(obj);
3707            TestCase.assertEquals((byte) 99, obj.key);
3708
3709            if (doUpdate) {
3710                index.put(obj);
3711            }
3712        }
3713
3714        @Override JavaDoc
3715        void copyRawObjects(RawStore rawStore, EntityStore newStore)
3716            throws DatabaseException {
3717
3718            PrimaryIndex<Byte JavaDoc,AllowPriKeyField_Byte2byte2>
3719                index = newStore.getPrimaryIndex
3720                    (Byte JavaDoc.class,
3721                     AllowPriKeyField_Byte2byte2.class);
3722            RawObject raw = rawStore.getPrimaryIndex(NAME).get((byte) 99);
3723            index.put((AllowPriKeyField_Byte2byte2)
3724                      newStore.getModel().convertRawObject(raw));
3725        }
3726
3727        @Override JavaDoc
3728        void readRawObjects(RawStore store,
3729                            boolean expectEvolved,
3730                            boolean expectUpdated)
3731            throws DatabaseException {
3732
3733            RawObject obj;
3734            if (expectEvolved) {
3735                obj = readRaw(store, (byte) 99, NAME, 1, CASECLS, 0);
3736            } else {
3737                obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3738            }
3739            checkRawFields(obj, "key", (byte) 99);
3740        }
3741    }
3742
3743    @Persistent(version=1)
3744    static class AllowFieldTypeChanges_Key {
3745
3746        AllowFieldTypeChanges_Key() {
3747            this(false);
3748        }
3749
3750        AllowFieldTypeChanges_Key(boolean init) {
3751            if (init) {
3752                f1 = true;
3753                f2 = (byte) 2;
3754                f3 = (short) 3;
3755                f4 = 4;
3756                f5 = 5L;
3757                f6 = 6F;
3758                f7 = 7D;
3759                f8 = (char) 8;
3760                f9 = true;
3761                f10 = (byte) 10;
3762                f11 = (short) 11;
3763                f12 = 12;
3764                f13 = 13L;
3765                f14 = 14F;
3766                f15 = 15D;
3767                f16 = (char) 16;
3768            }
3769        }
3770
3771        @KeyField(1)
3772        boolean f1;
3773
3774        @KeyField(2)
3775        byte f2;
3776
3777        @KeyField(3)
3778        short f3;
3779
3780        @KeyField(4)
3781        int f4;
3782
3783        @KeyField(5)
3784        long f5;
3785
3786        @KeyField(6)
3787        float f6;
3788
3789        @KeyField(7)
3790        double f7;
3791
3792        @KeyField(8)
3793        char f8;
3794
3795        @KeyField(9)
3796        Boolean JavaDoc f9;
3797
3798        @KeyField(10)
3799        Byte JavaDoc f10;
3800
3801        @KeyField(11)
3802        Short JavaDoc f11;
3803
3804        @KeyField(12)
3805        Integer JavaDoc f12;
3806
3807        @KeyField(13)
3808        Long JavaDoc f13;
3809
3810        @KeyField(14)
3811        Float JavaDoc f14;
3812
3813        @KeyField(15)
3814        Double JavaDoc f15;
3815
3816        @KeyField(16)
3817        Character JavaDoc f16;
3818    }
3819
3820    @Persistent(version=1)
3821    static class AllowFieldTypeChanges_Base
3822        extends EvolveCase {
3823
3824        @SecondaryKey(relate=ONE_TO_ONE)
3825        AllowFieldTypeChanges_Key kComposite;
3826
3827        Integer JavaDoc f_long2Integer;
3828        Long JavaDoc f_String2Long;
3829    }
3830
3831    /**
3832     * Allow field type changes: automatic widening, supported widening,
3833     * and Converter mutations. Also tests primary and secondary key field
3834     * renaming.
3835     */

3836    @Entity(version=1)
3837    static class AllowFieldTypeChanges
3838        extends AllowFieldTypeChanges_Base {
3839
3840        private static final String JavaDoc NAME =
3841            AllowFieldTypeChanges.class.getName();
3842        private static final String JavaDoc NAME2 =
3843            AllowFieldTypeChanges_Base.class.getName();
3844        private static final String JavaDoc NAME3 =
3845            AllowFieldTypeChanges_Key.class.getName();
3846
3847        @PrimaryKey
3848        Integer JavaDoc pkeyInteger;
3849
3850        @SecondaryKey(relate=ONE_TO_ONE)
3851        Boolean JavaDoc kBoolean;
3852
3853        @SecondaryKey(relate=ONE_TO_ONE)
3854        Byte JavaDoc kByte;
3855
3856        @SecondaryKey(relate=ONE_TO_ONE)
3857        Short JavaDoc kShort;
3858
3859        @SecondaryKey(relate=ONE_TO_ONE)
3860        Integer JavaDoc kInteger;
3861
3862        @SecondaryKey(relate=ONE_TO_ONE)
3863        Long JavaDoc kLong;
3864
3865        @SecondaryKey(relate=ONE_TO_ONE)
3866        Float JavaDoc kFloat;
3867
3868        @SecondaryKey(relate=ONE_TO_ONE)
3869        Double JavaDoc kDouble;
3870
3871        @SecondaryKey(relate=ONE_TO_ONE)
3872        Character JavaDoc kCharacter;
3873
3874        short f01;
3875        int f02;
3876        long f03;
3877        float f04;
3878        double f06;
3879        int f07;
3880        long f08;
3881        float f09;
3882        double f10;
3883        int f11;
3884        long f12;
3885        float f13;
3886        double f14;
3887        long f15;
3888        float f16;
3889        double f17;
3890        float f18;
3891        double f19;
3892        double f20;
3893
3894        Short JavaDoc f21;
3895        Integer JavaDoc f22;
3896        Long JavaDoc f23;
3897        Float JavaDoc f24;
3898        Double JavaDoc f26;
3899        Integer JavaDoc f27;
3900        Long JavaDoc f28;
3901        Float JavaDoc f29;
3902        Double JavaDoc f30;
3903        Integer JavaDoc f31;
3904        Long JavaDoc f32;
3905        Float JavaDoc f33;
3906        Double JavaDoc f34;
3907        Long JavaDoc f35;
3908        Float JavaDoc f36;
3909        Double JavaDoc f37;
3910        Float JavaDoc f38;
3911        Double JavaDoc f39;
3912        Double JavaDoc f40;
3913
3914        Short JavaDoc f41;
3915        Integer JavaDoc f42;
3916        Long JavaDoc f43;
3917        Float JavaDoc f44;
3918        Double JavaDoc f46;
3919        Integer JavaDoc f47;
3920        Long JavaDoc f48;
3921        Float JavaDoc f49;
3922        Double JavaDoc f50;
3923        Integer JavaDoc f51;
3924        Long JavaDoc f52;
3925        Float JavaDoc f53;
3926        Double JavaDoc f54;
3927        Long JavaDoc f55;
3928        Float JavaDoc f56;
3929        Double JavaDoc f57;
3930        Float JavaDoc f58;
3931        Double JavaDoc f59;
3932        Double JavaDoc f60;
3933
3934        BigInteger JavaDoc f70;
3935        BigInteger JavaDoc f71;
3936        BigInteger JavaDoc f72;
3937        BigInteger JavaDoc f73;
3938        BigInteger JavaDoc f74;
3939        BigInteger JavaDoc f75;
3940        BigInteger JavaDoc f76;
3941        BigInteger JavaDoc f77;
3942        BigInteger JavaDoc f78;
3943        BigInteger JavaDoc f79;
3944
3945        int f_long2int;
3946        long f_String2long;
3947
3948        @Override JavaDoc
3949        Mutations getMutations() {
3950            Mutations m = new Mutations();
3951            m.addRenamer(new Renamer(NAME, 0, "pkeyint", "pkeyInteger"));
3952            m.addRenamer(new Renamer(NAME, 0, "kboolean", "kBoolean"));
3953            m.addRenamer(new Renamer(NAME, 0, "kbyte", "kByte"));
3954            m.addRenamer(new Renamer(NAME, 0, "kshort", "kShort"));
3955            m.addRenamer(new Renamer(NAME, 0, "kint", "kInteger"));
3956            m.addRenamer(new Renamer(NAME, 0, "klong", "kLong"));
3957            m.addRenamer(new Renamer(NAME, 0, "kfloat", "kFloat"));
3958            m.addRenamer(new Renamer(NAME, 0, "kdouble", "kDouble"));
3959            m.addRenamer(new Renamer(NAME, 0, "kchar", "kCharacter"));
3960            m.addRenamer(new Renamer(NAME2, 0, "kcomposite", "kComposite"));
3961
3962            Conversion conv1 = new MyConversion1();
3963            Conversion conv2 = new MyConversion2();
3964        
3965            m.addConverter(new Converter(NAME, 0, "f_long2int", conv1));
3966            m.addConverter(new Converter(NAME, 0, "f_String2long", conv2));
3967            m.addConverter(new Converter(NAME2, 0, "f_long2Integer", conv1));
3968            m.addConverter(new Converter(NAME2, 0, "f_String2Long", conv2));
3969            return m;
3970        }
3971
3972        static class MyConversion1 implements Conversion {
3973
3974            public void initialize(EntityModel model) {}
3975
3976            public Object JavaDoc convert(Object JavaDoc o) {
3977                return ((Long JavaDoc) o).intValue();
3978            }
3979            
3980            @Override JavaDoc
3981            public boolean equals(Object JavaDoc other) { return true; }
3982        }
3983
3984        static class MyConversion2 implements Conversion {
3985
3986            public void initialize(EntityModel model) {}
3987
3988            public Object JavaDoc convert(Object JavaDoc o) {
3989                return Long.valueOf((String JavaDoc) o);
3990            }
3991
3992            @Override JavaDoc
3993            public boolean equals(Object JavaDoc other) { return true; }
3994        }
3995
3996        @Override JavaDoc
3997        void checkEvolvedModel(EntityModel model,
3998                               Environment env,
3999                               boolean oldTypesExist) {
4000            checkEntity(true, model, env, NAME, 1, null);
4001            checkNonEntity(true, model, env, NAME2, 1);
4002            if (oldTypesExist) {
4003                checkVersions(model, NAME, 1, NAME, 0);
4004                checkVersions(model, NAME2, 1, NAME2, 0);
4005                checkVersions(model, NAME3, 1, NAME3, 0);
4006            } else {
4007                checkVersions(model, NAME, 1);
4008                checkVersions(model, NAME2, 1);
4009                checkVersions(model, NAME3, 1);
4010            }
4011        }
4012
4013        @Override JavaDoc
4014        void readObjects(EntityStore store, boolean doUpdate)
4015            throws DatabaseException {
4016
4017            PrimaryIndex<Integer JavaDoc,AllowFieldTypeChanges>
4018                index = store.getPrimaryIndex
4019                    (Integer JavaDoc.class, AllowFieldTypeChanges.class);
4020            AllowFieldTypeChanges obj = index.get((int) 99);
4021            checkValues(obj);
4022            checkSecondaries(store, index);
4023
4024            if (doUpdate) {
4025                index.put(obj);
4026                checkSecondaries(store, index);
4027            }
4028        }
4029
4030        @Override JavaDoc
4031        void copyRawObjects(RawStore rawStore, EntityStore newStore)
4032            throws DatabaseException {
4033
4034            PrimaryIndex<Integer JavaDoc,AllowFieldTypeChanges>
4035                index = newStore.getPrimaryIndex
4036                    (Integer JavaDoc.class, AllowFieldTypeChanges.class);
4037            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4038            index.put((AllowFieldTypeChanges)
4039                      newStore.getModel().convertRawObject(raw));
4040        }
4041
4042        private void checkSecondaries(EntityStore store,
4043                                      PrimaryIndex<Integer JavaDoc,
4044                                                   AllowFieldTypeChanges>
4045                                                   index)
4046            throws DatabaseException {
4047
4048            checkValues(store.getSecondaryIndex
4049                (index, Boolean JavaDoc.class, "kBoolean").get(true));
4050            checkValues(store.getSecondaryIndex
4051                (index, Byte JavaDoc.class, "kByte").get((byte) 77));
4052            checkValues(store.getSecondaryIndex
4053                (index, Short JavaDoc.class, "kShort").get((short) 66));
4054            checkValues(store.getSecondaryIndex
4055                (index, Integer JavaDoc.class, "kInteger").get((int) 55));
4056            checkValues(store.getSecondaryIndex
4057                (index, Long JavaDoc.class, "kLong").get((long) 44));
4058            checkValues(store.getSecondaryIndex
4059                (index, Float JavaDoc.class, "kFloat").get((float) 33));
4060            checkValues(store.getSecondaryIndex
4061                (index, Double JavaDoc.class, "kDouble").get((double) 22));
4062            checkValues(store.getSecondaryIndex
4063                (index, Character JavaDoc.class, "kCharacter").get((char) 11));
4064            checkValues(store.getSecondaryIndex
4065                (index, AllowFieldTypeChanges_Key.class, "kComposite").get
4066                    (new AllowFieldTypeChanges_Key(true)));
4067        }
4068
4069        private void checkValues(AllowFieldTypeChanges obj) {
4070            TestCase.assertNotNull(obj);
4071            TestCase.assertEquals(obj.pkeyInteger, Integer.valueOf(99));
4072            TestCase.assertEquals(obj.kBoolean, Boolean.valueOf(true));
4073            TestCase.assertEquals(obj.kByte, Byte.valueOf((byte) 77));
4074            TestCase.assertEquals(obj.kShort, Short.valueOf((short) 66));
4075            TestCase.assertEquals(obj.kInteger, Integer.valueOf(55));
4076            TestCase.assertEquals(obj.kLong, Long.valueOf(44));
4077            TestCase.assertEquals(obj.kFloat, Float.valueOf(33));
4078            TestCase.assertEquals(obj.kDouble, Double.valueOf(22));
4079            TestCase.assertEquals(obj.kCharacter, Character.valueOf((char) 11));
4080
4081            AllowFieldTypeChanges_Key embed = obj.kComposite;
4082            TestCase.assertNotNull(embed);
4083            TestCase.assertEquals(embed.f1, true);
4084            TestCase.assertEquals(embed.f2, (byte) 2);
4085            TestCase.assertEquals(embed.f3, (short) 3);
4086            TestCase.assertEquals(embed.f4, 4);
4087            TestCase.assertEquals(embed.f5, 5L);
4088            TestCase.assertEquals(embed.f6, 6F);
4089            TestCase.assertEquals(embed.f7, 7D);
4090            TestCase.assertEquals(embed.f8, (char) 8);
4091            TestCase.assertEquals(embed.f9, Boolean.valueOf(true));
4092            TestCase.assertEquals(embed.f10, Byte.valueOf((byte) 10));
4093            TestCase.assertEquals(embed.f11, Short.valueOf((short) 11));
4094            TestCase.assertEquals(embed.f12, Integer.valueOf(12));
4095            TestCase.assertEquals(embed.f13, Long.valueOf(13L));
4096            TestCase.assertEquals(embed.f14, Float.valueOf(14F));
4097            TestCase.assertEquals(embed.f15, Double.valueOf(15D));
4098            TestCase.assertEquals(embed.f16, Character.valueOf((char) 16));
4099
4100            TestCase.assertEquals(obj.f01, (short) 1);
4101            TestCase.assertEquals(obj.f02, (int) 2);
4102            TestCase.assertEquals(obj.f03, (long) 3);
4103            TestCase.assertEquals(obj.f04, (float) 4);
4104            TestCase.assertEquals(obj.f06, (double) 6);
4105            TestCase.assertEquals(obj.f07, (int) 7);
4106            TestCase.assertEquals(obj.f08, (long) 8);
4107            TestCase.assertEquals(obj.f09, (float) 9);
4108            TestCase.assertEquals(obj.f10, (double) 10);
4109            TestCase.assertEquals(obj.f11, (int) 11);
4110            TestCase.assertEquals(obj.f12, (long) 12);
4111            TestCase.assertEquals(obj.f13, (float) 13);
4112            TestCase.assertEquals(obj.f14, (double) 14);
4113            TestCase.assertEquals(obj.f15, 15L);
4114            TestCase.assertEquals(obj.f16, 16F);
4115            TestCase.assertEquals(obj.f17, 17D);
4116            TestCase.assertEquals(obj.f18, (float) 18);
4117            TestCase.assertEquals(obj.f19, (double) 19);
4118            TestCase.assertEquals(obj.f20, (double) 20);
4119
4120            TestCase.assertEquals(obj.f21, Short.valueOf((byte) 21));
4121            TestCase.assertEquals(obj.f22, Integer.valueOf((byte) 22));
4122            TestCase.assertEquals(obj.f23, Long.valueOf((byte) 23));
4123            TestCase.assertEquals(obj.f24, Float.valueOf((byte) 24));
4124            TestCase.assertEquals(obj.f26, Double.valueOf((byte) 26));
4125            TestCase.assertEquals(obj.f27, Integer.valueOf((short) 27));
4126            TestCase.assertEquals(obj.f28, Long.valueOf((short) 28));
4127            TestCase.assertEquals(obj.f29, Float.valueOf((short) 29));
4128            TestCase.assertEquals(obj.f30, Double.valueOf((short) 30));
4129            TestCase.assertEquals(obj.f31, Integer.valueOf((char) 31));
4130            TestCase.assertEquals(obj.f32, Long.valueOf((char) 32));
4131            TestCase.assertEquals(obj.f33, Float.valueOf((char) 33));
4132            TestCase.assertEquals(obj.f34, Double.valueOf((char) 34));
4133            TestCase.assertEquals(obj.f35, Long.valueOf(35));
4134            TestCase.assertEquals(obj.f36, Float.valueOf(36));
4135            TestCase.assertEquals(obj.f37, Double.valueOf(37));
4136            TestCase.assertEquals(obj.f38, Float.valueOf((long) 38));
4137            TestCase.assertEquals(obj.f39, Double.valueOf((long) 39));
4138            TestCase.assertEquals(obj.f40, Double.valueOf((float) 40));
4139
4140            TestCase.assertEquals(obj.f41, Short.valueOf((byte) 41));
4141            TestCase.assertEquals(obj.f42, Integer.valueOf((byte) 42));
4142            TestCase.assertEquals(obj.f43, Long.valueOf((byte) 43));
4143            TestCase.assertEquals(obj.f44, Float.valueOf((byte) 44));
4144            TestCase.assertEquals(obj.f46, Double.valueOf((byte) 46));
4145            TestCase.assertEquals(obj.f47, Integer.valueOf((short) 47));
4146            TestCase.assertEquals(obj.f48, Long.valueOf((short) 48));
4147            TestCase.assertEquals(obj.f49, Float.valueOf((short) 49));
4148            TestCase.assertEquals(obj.f50, Double.valueOf((short) 50));
4149            TestCase.assertEquals(obj.f51, Integer.valueOf((char) 51));
4150            TestCase.assertEquals(obj.f52, Long.valueOf((char) 52));
4151            TestCase.assertEquals(obj.f53, Float.valueOf((char) 53));
4152            TestCase.assertEquals(obj.f54, Double.valueOf((char) 54));
4153            TestCase.assertEquals(obj.f55, Long.valueOf(55));
4154            TestCase.assertEquals(obj.f56, Float.valueOf(56));
4155            TestCase.assertEquals(obj.f57, Double.valueOf(57));
4156            TestCase.assertEquals(obj.f58, Float.valueOf((long) 58));
4157            TestCase.assertEquals(obj.f59, Double.valueOf((long) 59));
4158            TestCase.assertEquals(obj.f60, Double.valueOf((float) 60));
4159
4160            TestCase.assertEquals(obj.f70, BigInteger.valueOf(70));
4161            TestCase.assertEquals(obj.f71, BigInteger.valueOf(71));
4162            TestCase.assertEquals(obj.f72, BigInteger.valueOf(72));
4163            TestCase.assertEquals(obj.f73, BigInteger.valueOf(73));
4164            TestCase.assertEquals(obj.f74, BigInteger.valueOf(74));
4165            TestCase.assertEquals(obj.f75, BigInteger.valueOf(75));
4166            TestCase.assertEquals(obj.f76, BigInteger.valueOf(76));
4167            TestCase.assertEquals(obj.f77, BigInteger.valueOf(77));
4168            TestCase.assertEquals(obj.f78, BigInteger.valueOf(78));
4169            TestCase.assertEquals(obj.f79, BigInteger.valueOf(79));
4170
4171            TestCase.assertEquals(obj.f_long2Integer, Integer.valueOf(111));
4172            TestCase.assertEquals(obj.f_String2Long, Long.valueOf(222));
4173            TestCase.assertEquals(obj.f_long2int, 333);
4174            TestCase.assertEquals(obj.f_String2long, 444L);
4175        }
4176
4177        @Override JavaDoc
4178        void readRawObjects(RawStore store,
4179                            boolean expectEvolved,
4180                            boolean expectUpdated)
4181            throws DatabaseException {
4182
4183            RawType embedType = store.getModel().getRawType(NAME3);
4184            RawObject embed = new RawObject
4185                (embedType,
4186                 makeValues
4187                    ("f1", true,
4188                     "f2", (byte) 2,
4189                     "f3", (short) 3,
4190                     "f4", 4,
4191                     "f5", 5L,
4192                     "f6", 6F,
4193                     "f7", 7D,
4194                     "f8", (char) 8,
4195                     "f9", true,
4196                     "f10", (byte) 10,
4197                     "f11", (short) 11,
4198                     "f12", 12,
4199                     "f13", 13L,
4200                     "f14", 14F,
4201                     "f15", 15D,
4202                     "f16", (char) 16),
4203                 null);
4204
4205            RawObject obj;
4206            if (expectEvolved) {
4207                obj = readRaw(store, 99, NAME, 1, NAME2, 1, CASECLS, 0);
4208                checkRawFields(obj, "pkeyInteger", (int) 99,
4209                               "kBoolean", true,
4210                               "kByte", (byte) 77,
4211                               "kShort", (short) 66,
4212                               "kInteger", (int) 55,
4213                               "kLong", (long) 44,
4214                               "kFloat", (float) 33,
4215                               "kDouble", (double) 22,
4216                               "kCharacter", (char) 11,
4217
4218                               "f01", (short) 1,
4219                               "f02", (int) 2,
4220                               "f03", (long) 3,
4221                               "f04", (float) 4,
4222                               "f06", (double) 6,
4223                               "f07", (int) 7,
4224                               "f08", (long) 8,
4225                               "f09", (float) 9,
4226                               "f10", (double) 10,
4227                               "f11", (int) 11,
4228                               "f12", (long) 12,
4229                               "f13", (float) 13,
4230                               "f14", (double) 14,
4231                               "f15", 15L,
4232                               "f16", 16F,
4233                               "f17", 17D,
4234                               "f18", (float) 18,
4235                               "f19", (double) 19,
4236                               "f20", (double) 20,
4237
4238                               "f21", (short) 21,
4239                               "f22", (int) 22,
4240                               "f23", (long) 23,
4241                               "f24", (float) 24,
4242                               "f26", (double) 26,
4243                               "f27", (int) 27,
4244                               "f28", (long) 28,
4245                               "f29", (float) 29,
4246                               "f30", (double) 30,
4247                               "f31", (int) 31,
4248                               "f32", (long) 32,
4249                               "f33", (float) 33,
4250                               "f34", (double) 34,
4251                               "f35", 35L,
4252                               "f36", 36F,
4253                               "f37", 37D,
4254                               "f38", (float) 38,
4255                               "f39", (double) 39,
4256                               "f40", (double) 40,
4257
4258                               "f41", (short) 41,
4259                               "f42", (int) 42,
4260                               "f43", (long) 43,
4261                               "f44", (float) 44,
4262                               "f46", (double) 46,
4263                               "f47", (int) 47,
4264                               "f48", (long) 48,
4265                               "f49", (float) 49,
4266                               "f50", (double) 50,
4267                               "f51", (int) 51,
4268                               "f52", (long) 52,
4269                               "f53", (float) 53,
4270                               "f54", (double) 54,
4271                               "f55", 55L,
4272                               "f56", 56F,
4273                               "f57", 57D,
4274                               "f58", (float) 58,
4275                               "f59", (double) 59,
4276                               "f60", (double) 60,
4277
4278                               "f70", BigInteger.valueOf(70),
4279                               "f71", BigInteger.valueOf(71),
4280                               "f72", BigInteger.valueOf(72),
4281                               "f73", BigInteger.valueOf(73),
4282                               "f74", BigInteger.valueOf(74),
4283                               "f75", BigInteger.valueOf(75),
4284                               "f76", BigInteger.valueOf(76),
4285                               "f77", BigInteger.valueOf(77),
4286                               "f78", BigInteger.valueOf(78),
4287                               "f79", BigInteger.valueOf(79),
4288
4289                               "f_long2int", 333,
4290                               "f_String2long", 444L);
4291                checkRawFields(obj.getSuper(),
4292                               "kComposite", embed,
4293                               "f_long2Integer", 111,
4294                               "f_String2Long", 222L);
4295            } else {
4296                obj = readRaw(store, 99, NAME, 0, NAME2, 0, CASECLS, 0);
4297                checkRawFields(obj, "pkeyint", (int) 99,
4298                               "kboolean", true,
4299                               "kbyte", (byte) 77,
4300                               "kshort", (short) 66,
4301                               "kint", (int) 55,
4302                               "klong", (long) 44,
4303                               "kfloat", (float) 33,
4304                               "kdouble", (double) 22,
4305                               "kchar", (char) 11,
4306
4307                               "f01", (byte) 1,
4308                               "f02", (byte) 2,
4309                               "f03", (byte) 3,
4310                               "f04", (byte) 4,
4311                               "f06", (byte) 6,
4312                               "f07", (short) 7,
4313                               "f08", (short) 8,
4314                               "f09", (short) 9,
4315                               "f10", (short) 10,
4316                               "f11", (char) 11,
4317                               "f12", (char) 12,
4318                               "f13", (char) 13,
4319                               "f14", (char) 14,
4320                               "f15", 15,
4321                               "f16", 16,
4322                               "f17", 17,
4323                               "f18", (long) 18,
4324                               "f19", (long) 19,
4325                               "f20", (float) 20,
4326
4327                               "f21", (byte) 21,
4328                               "f22", (byte) 22,
4329                               "f23", (byte) 23,
4330                               "f24", (byte) 24,
4331                               "f26", (byte) 26,
4332                               "f27", (short) 27,
4333                               "f28", (short) 28,
4334                               "f29", (short) 29,
4335                               "f30", (short) 30,
4336                               "f31", (char) 31,
4337                               "f32", (char) 32,
4338                               "f33", (char) 33,
4339                               "f34", (char) 34,
4340                               "f35", 35,
4341                               "f36", 36,
4342                               "f37", 37,
4343                               "f38", (long) 38,
4344                               "f39", (long) 39,
4345                               "f40", (float) 40,
4346
4347                               "f41", (byte) 41,
4348                               "f42", (byte) 42,
4349                               "f43", (byte) 43,
4350                               "f44", (byte) 44,
4351                               "f46", (byte) 46,
4352                               "f47", (short) 47,
4353                               "f48", (short) 48,
4354                               "f49", (short) 49,
4355                               "f50", (short) 50,
4356                               "f51", (char) 51,
4357                               "f52", (char) 52,
4358                               "f53", (char) 53,
4359                               "f54", (char) 54,
4360                               "f55", 55,
4361                               "f56", 56,
4362                               "f57", 57,
4363                               "f58", (long) 58,
4364                               "f59", (long) 59,
4365                               "f60", (float) 60,
4366
4367                               "f70", (byte) 70,
4368                               "f71", (short) 71,
4369                               "f72", (char) 72,
4370                               "f73", 73,
4371                               "f74", (long) 74,
4372                               "f75", (byte) 75,
4373                               "f76", (short) 76,
4374                               "f77", (char) 77,
4375                               "f78", 78,
4376                               "f79", (long) 79,
4377
4378                               "f_long2int", 333L,
4379                               "f_String2long", "444");
4380
4381                checkRawFields(obj.getSuper(),
4382                               "kcomposite", embed,
4383                               "f_long2Integer", 111L,
4384                               "f_String2Long", "222");
4385            }
4386            Environment env = store.getEnvironment();
4387
4388            assertDbExists(expectEvolved, env, NAME, "kBoolean");
4389            assertDbExists(expectEvolved, env, NAME, "kByte");
4390            assertDbExists(expectEvolved, env, NAME, "kShort");
4391            assertDbExists(expectEvolved, env, NAME, "kInteger");
4392            assertDbExists(expectEvolved, env, NAME, "kLong");
4393            assertDbExists(expectEvolved, env, NAME, "kFloat");
4394            assertDbExists(expectEvolved, env, NAME, "kDouble");
4395            assertDbExists(expectEvolved, env, NAME, "kCharacter");
4396            assertDbExists(expectEvolved, env, NAME, "kComposite");
4397
4398            assertDbExists(!expectEvolved, env, NAME, "kboolean");
4399            assertDbExists(!expectEvolved, env, NAME, "kbyte");
4400            assertDbExists(!expectEvolved, env, NAME, "kshort");
4401            assertDbExists(!expectEvolved, env, NAME, "kint");
4402            assertDbExists(!expectEvolved, env, NAME, "klong");
4403            assertDbExists(!expectEvolved, env, NAME, "kfloat");
4404            assertDbExists(!expectEvolved, env, NAME, "kdouble");
4405            assertDbExists(!expectEvolved, env, NAME, "kchar");
4406            assertDbExists(!expectEvolved, env, NAME, "kcomposite");
4407        }
4408    }
4409
4410    @Persistent(version=1)
4411    static class ConvertExample1_Address {
4412        String JavaDoc street;
4413        String JavaDoc city;
4414        String JavaDoc state;
4415        int zipCode;
4416    }
4417
4418    static class ConvertExample1_Conversion implements Conversion {
4419
4420        public void initialize(EntityModel model) {
4421        }
4422
4423        public Object JavaDoc convert(Object JavaDoc fromValue) {
4424            return Integer.valueOf((String JavaDoc) fromValue);
4425        }
4426        
4427        @Override JavaDoc
4428        public boolean equals(Object JavaDoc o) {
4429            return o instanceof ConvertExample1_Conversion;
4430        }
4431    }
4432
4433    @Entity
4434    static class ConvertExample1_Entity
4435        extends EvolveCase {
4436
4437        private static final String JavaDoc NAME =
4438            ConvertExample1_Entity.class.getName();
4439        private static final String JavaDoc NAME2 =
4440            ConvertExample1_Address.class.getName();
4441
4442        @PrimaryKey
4443        int key = 99;
4444
4445        ConvertExample1_Address embed;
4446
4447        @Override JavaDoc
4448        Mutations getMutations() {
4449            Mutations m = new Mutations();
4450            Converter converter = new Converter
4451                (ConvertExample1_Address.class.getName(), 0,
4452                 "zipCode", new ConvertExample1_Conversion());
4453            m.addConverter(converter);
4454            return m;
4455        }
4456
4457        @Override JavaDoc
4458        void checkEvolvedModel(EntityModel model,
4459                               Environment env,
4460                               boolean oldTypesExist) {
4461            checkEntity(true, model, env, NAME, 0, null);
4462            checkVersions(model, NAME, 0);
4463            if (oldTypesExist) {
4464                checkVersions(model, NAME2, 1, NAME2, 0);
4465            } else {
4466                checkVersions(model, NAME2, 1);
4467            }
4468        }
4469
4470        @Override JavaDoc
4471        void readObjects(EntityStore store, boolean doUpdate)
4472            throws DatabaseException {
4473
4474            PrimaryIndex<Integer JavaDoc,ConvertExample1_Entity>
4475                index = store.getPrimaryIndex
4476                    (Integer JavaDoc.class,
4477                     ConvertExample1_Entity.class);
4478            ConvertExample1_Entity obj = index.get(99);
4479            TestCase.assertNotNull(obj);
4480            TestCase.assertEquals(99, obj.key);
4481            TestCase.assertNotNull(obj.embed);
4482            TestCase.assertEquals("street", obj.embed.street);
4483            TestCase.assertEquals("city", obj.embed.city);
4484            TestCase.assertEquals("state", obj.embed.state);
4485            TestCase.assertEquals(12345, obj.embed.zipCode);
4486
4487            if (doUpdate) {
4488                index.put(obj);
4489            }
4490        }
4491
4492        @Override JavaDoc
4493        void copyRawObjects(RawStore rawStore, EntityStore newStore)
4494            throws DatabaseException {
4495
4496            PrimaryIndex<Integer JavaDoc,ConvertExample1_Entity>
4497                index = newStore.getPrimaryIndex
4498                    (Integer JavaDoc.class,
4499                     ConvertExample1_Entity.class);
4500            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4501            index.put((ConvertExample1_Entity)
4502                      newStore.getModel().convertRawObject(raw));
4503        }
4504
4505        @Override JavaDoc
4506        void readRawObjects(RawStore store,
4507                            boolean expectEvolved,
4508                            boolean expectUpdated)
4509            throws DatabaseException {
4510
4511            RawType embedType = store.getModel().getRawType(NAME2);
4512            RawObject embed;
4513            if (expectEvolved) {
4514                embed = new RawObject
4515                    (embedType,
4516                     makeValues("street", "street",
4517                                "city", "city",
4518                                "state", "state",
4519                                "zipCode", 12345),
4520                     null);
4521            } else {
4522                embed = new RawObject
4523                    (embedType,
4524                     makeValues("street", "street",
4525                                "city", "city",
4526                                "state", "state",
4527                                "zipCode", "12345"),
4528                     null);
4529            }
4530            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
4531            checkRawFields(obj, "key", 99, "embed", embed);
4532        }
4533    }
4534
4535    @Persistent
4536    static class ConvertExample2_Address {
4537        String JavaDoc street;
4538        String JavaDoc city;
4539        String JavaDoc state;
4540        int zipCode;
4541    }
4542
4543    @Entity(version=1)
4544    static class ConvertExample2_Person
4545        extends EvolveCase {
4546
4547        private static final String JavaDoc NAME =
4548            ConvertExample2_Person.class.getName();
4549        private static final String JavaDoc NAME2 =
4550            ConvertExample2_Address .class.getName();
4551
4552        @PrimaryKey
4553        int key;
4554
4555        ConvertExample2_Address address;
4556
4557        @Override JavaDoc
4558        Mutations getMutations() {
4559            Mutations m = new Mutations();
4560            Converter converter = new Converter
4561                (ConvertExample2_Person.class.getName(), 0,
4562                 "address", new ConvertExample2_Conversion());
4563            m.addConverter(converter);
4564            return m;
4565        }
4566
4567        @Override JavaDoc
4568        void checkEvolvedModel(EntityModel model,
4569                               Environment env,
4570                               boolean oldTypesExist) {
4571            checkEntity(true, model, env, NAME, 1, null);
4572            if (oldTypesExist) {
4573                checkVersions(model, NAME, 1, NAME, 0);
4574            } else {
4575                checkVersions(model, NAME, 1);
4576            }
4577            checkVersions(model, NAME2, 0);
4578        }
4579
4580        @Override JavaDoc
4581        void readObjects(EntityStore store, boolean doUpdate)
4582            throws DatabaseException {
4583
4584            PrimaryIndex<Integer JavaDoc,ConvertExample2_Person>
4585                index = store.getPrimaryIndex
4586                    (Integer JavaDoc.class,
4587                     ConvertExample2_Person.class);
4588            ConvertExample2_Person obj = index.get(99);
4589            TestCase.assertNotNull(obj);
4590            TestCase.assertEquals(99, obj.key);
4591            TestCase.assertNotNull(obj.address);
4592            TestCase.assertEquals("street", obj.address.street);
4593            TestCase.assertEquals("city", obj.address.city);
4594            TestCase.assertEquals("state", obj.address.state);
4595            TestCase.assertEquals(12345, obj.address.zipCode);
4596
4597            if (doUpdate) {
4598                index.put(obj);
4599            }
4600        }
4601
4602        @Override JavaDoc
4603        void copyRawObjects(RawStore rawStore, EntityStore newStore)
4604            throws DatabaseException {
4605
4606            PrimaryIndex<Integer JavaDoc,ConvertExample2_Person>
4607                index = newStore.getPrimaryIndex
4608                    (Integer JavaDoc.class,
4609                     ConvertExample2_Person.class);
4610            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4611            index.put((ConvertExample2_Person)
4612                      newStore.getModel().convertRawObject(raw));
4613        }
4614
4615        @Override JavaDoc
4616        void readRawObjects(RawStore store,
4617                            boolean expectEvolved,
4618                            boolean expectUpdated)
4619            throws DatabaseException {
4620
4621            Object JavaDoc embed;
4622            if (expectEvolved) {
4623                RawType embedType = store.getModel().getRawType(NAME2);
4624                embed = new RawObject
4625                    (embedType,
4626                     makeValues("street", "street",
4627                                "city", "city",
4628                                "state", "state",
4629                                "zipCode", 12345),
4630                     null);
4631            } else {
4632                embed = "street#city#state#12345";
4633            }
4634            RawObject obj = readRaw
4635                (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4636            checkRawFields(obj, "key", 99, "address", embed);
4637        }
4638    }
4639
4640    static class ConvertExample2_Conversion implements Conversion {
4641        private transient RawType addressType;
4642
4643        public void initialize(EntityModel model) {
4644            addressType = model.getRawType
4645                (ConvertExample2_Address.class.getName());
4646        }
4647
4648        public Object JavaDoc convert(Object JavaDoc fromValue) {
4649
4650            String JavaDoc oldAddress = (String JavaDoc) fromValue;
4651            Map JavaDoc<String JavaDoc,Object JavaDoc> addressValues = new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
4652            addressValues.put("street", parseAddress(1, oldAddress));
4653            addressValues.put("city", parseAddress(2, oldAddress));
4654            addressValues.put("state", parseAddress(3, oldAddress));
4655            addressValues.put("zipCode",
4656                              Integer.valueOf(parseAddress(4, oldAddress)));
4657
4658            return new RawObject(addressType, addressValues, null);
4659        }
4660        
4661        @Override JavaDoc
4662        public boolean equals(Object JavaDoc o) {
4663            return o instanceof ConvertExample2_Conversion;
4664        }
4665
4666        private String JavaDoc parseAddress(int fieldNum, String JavaDoc oldAddress) {
4667            StringTokenizer JavaDoc tokens = new StringTokenizer JavaDoc(oldAddress, "#");
4668            String JavaDoc field = null;
4669            for (int i = 0; i < fieldNum; i += 1) {
4670                field = tokens.nextToken();
4671            }
4672            return field;
4673        }
4674    }
4675
4676    @Persistent
4677    static class ConvertExample3_Address {
4678        String JavaDoc street;
4679        String JavaDoc city;
4680        String JavaDoc state;
4681        int zipCode;
4682    }
4683
4684    static class ConvertExample3_Conversion implements Conversion {
4685        private transient RawType newPersonType;
4686        private transient RawType addressType;
4687
4688        public void initialize(EntityModel model) {
4689            newPersonType = model.getRawType
4690                (ConvertExample3_Person.class.getName());
4691            addressType = model.getRawType
4692                (ConvertExample3_Address.class.getName());
4693        }
4694
4695        public Object JavaDoc convert(Object JavaDoc fromValue) {
4696
4697            RawObject person = (RawObject) fromValue;
4698            Map JavaDoc<String JavaDoc,Object JavaDoc> personValues = person.getValues();
4699            Map JavaDoc<String JavaDoc,Object JavaDoc> addressValues = new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
4700            RawObject address = new RawObject
4701                (addressType, addressValues, null);
4702
4703            addressValues.put("street", personValues.remove("street"));
4704            addressValues.put("city", personValues.remove("city"));
4705            addressValues.put("state", personValues.remove("state"));
4706            addressValues.put("zipCode", personValues.remove("zipCode"));
4707            personValues.put("address", address);
4708
4709            return new RawObject
4710                (newPersonType, personValues, person.getSuper());
4711        }
4712        
4713        @Override JavaDoc
4714        public boolean equals(Object JavaDoc o) {
4715            return o instanceof ConvertExample3_Conversion;
4716        }
4717    }
4718
4719    @Entity(version=1)
4720    static class ConvertExample3_Person
4721        extends EvolveCase {
4722
4723        private static final String JavaDoc NAME =
4724            ConvertExample3_Person.class.getName();
4725        private static final String JavaDoc NAME2 =
4726            ConvertExample3_Address .class.getName();
4727
4728        @PrimaryKey
4729        int key;
4730
4731        ConvertExample3_Address address;
4732
4733        @Override JavaDoc
4734        Mutations getMutations() {
4735            Mutations m = new Mutations();
4736            Converter converter = new Converter
4737                (ConvertExample3_Person.class.getName(), 0,
4738                 new ConvertExample3_Conversion());
4739            m.addConverter(converter);
4740            return m;
4741        }
4742
4743        @Override JavaDoc
4744        void checkEvolvedModel(EntityModel model,
4745                               Environment env,
4746                               boolean oldTypesExist) {
4747            checkEntity(true, model, env, NAME, 1, null);
4748            if (oldTypesExist) {
4749                checkVersions(model, NAME, 1, NAME, 0);
4750            } else {
4751                checkVersions(model, NAME, 1);
4752            }
4753            checkVersions(model, NAME2, 0);
4754        }
4755
4756        @Override JavaDoc
4757        void readObjects(EntityStore store, boolean doUpdate)
4758            throws DatabaseException {
4759
4760            PrimaryIndex<Integer JavaDoc,ConvertExample3_Person>
4761                index = store.getPrimaryIndex
4762                    (Integer JavaDoc.class,
4763                     ConvertExample3_Person.class);
4764            ConvertExample3_Person obj = index.get(99);
4765            TestCase.assertNotNull(obj);
4766            TestCase.assertEquals(99, obj.key);
4767            TestCase.assertNotNull(obj.address);
4768            TestCase.assertEquals("street", obj.address.street);
4769            TestCase.assertEquals("city", obj.address.city);
4770            TestCase.assertEquals("state", obj.address.state);
4771            TestCase.assertEquals(12345, obj.address.zipCode);
4772
4773            if (doUpdate) {
4774                index.put(obj);
4775            }
4776        }
4777
4778        @Override JavaDoc
4779        void copyRawObjects(RawStore rawStore, EntityStore newStore)
4780            throws DatabaseException {
4781
4782            PrimaryIndex<Integer JavaDoc,ConvertExample3_Person>
4783                index = newStore.getPrimaryIndex
4784                    (Integer JavaDoc.class,
4785                     ConvertExample3_Person.class);
4786            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4787            index.put((ConvertExample3_Person)
4788                      newStore.getModel().convertRawObject(raw));
4789        }
4790
4791        @Override JavaDoc
4792        void readRawObjects(RawStore store,
4793                            boolean expectEvolved,
4794                            boolean expectUpdated)
4795            throws DatabaseException {
4796
4797            RawObject obj = readRaw
4798                (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4799            if (expectEvolved) {
4800                RawType embedType = store.getModel().getRawType(NAME2);
4801                Object JavaDoc embed = new RawObject
4802                    (embedType,
4803                     makeValues("street", "street",
4804                                "city", "city",
4805                                "state", "state",
4806                                "zipCode", 12345),
4807                     null);
4808                checkRawFields(obj, "key", 99, "address", embed);
4809            } else {
4810                checkRawFields(obj, "key", 99,
4811                                    "street", "street",
4812                                    "city", "city",
4813                                    "state", "state",
4814                                    "zipCode", 12345);
4815            }
4816        }
4817    }
4818
4819    @Persistent(version=1)
4820    static class ConvertExample4_A extends ConvertExample4_B {
4821    }
4822
4823    @Persistent(version=1)
4824    static class ConvertExample4_B {
4825        String JavaDoc name;
4826    }
4827
4828    static class Example4_Conversion implements Conversion {
4829        private transient RawType newAType;
4830        private transient RawType newBType;
4831
4832        public void initialize(EntityModel model) {
4833            newAType = model.getRawType(ConvertExample4_A.class.getName());
4834            newBType = model.getRawType(ConvertExample4_B.class.getName());
4835        }
4836
4837        public Object JavaDoc convert(Object JavaDoc fromValue) {
4838            RawObject oldA = (RawObject) fromValue;
4839            RawObject oldB = oldA.getSuper();
4840            Map JavaDoc<String JavaDoc,Object JavaDoc> aValues = oldA.getValues();
4841            Map JavaDoc<String JavaDoc,Object JavaDoc> bValues = oldB.getValues();
4842            bValues.put("name", aValues.remove("name"));
4843            RawObject newB = new RawObject(newBType, bValues, oldB.getSuper());
4844            RawObject newA = new RawObject(newAType, aValues, newB);
4845            return newA;
4846        }
4847        
4848        @Override JavaDoc
4849        public boolean equals(Object JavaDoc o) {
4850            return o instanceof Example4_Conversion;
4851        }
4852    }
4853
4854    @Entity(version=1)
4855    static class ConvertExample4_Entity
4856        extends EvolveCase {
4857
4858        private static final String JavaDoc NAME =
4859            ConvertExample4_Entity.class.getName();
4860        private static final String JavaDoc NAME2 =
4861            ConvertExample4_A .class.getName();
4862        private static final String JavaDoc NAME3 =
4863            ConvertExample4_B .class.getName();
4864
4865        @PrimaryKey
4866        int key;
4867
4868        ConvertExample4_A embed;
4869
4870        @Override JavaDoc
4871        Mutations getMutations() {
4872            Mutations m = new Mutations();
4873            Converter converter = new Converter
4874                (ConvertExample4_A.class.getName(), 0,
4875                 new Example4_Conversion());
4876            m.addConverter(converter);
4877            return m;
4878        }
4879
4880        @Override JavaDoc
4881        void checkEvolvedModel(EntityModel model,
4882                               Environment env,
4883                               boolean oldTypesExist) {
4884            checkEntity(true, model, env, NAME, 1, null);
4885            if (oldTypesExist) {
4886                checkVersions(model, NAME, 1, NAME, 0);
4887                checkVersions(model, NAME2, 1, NAME2, 0);
4888                checkVersions(model, NAME3, 1, NAME3, 0);
4889            } else {
4890                checkVersions(model, NAME, 1);
4891                checkVersions(model, NAME2, 1);
4892                checkVersions(model, NAME3, 1);
4893            }
4894        }
4895
4896        @Override JavaDoc
4897        void readObjects(EntityStore store, boolean doUpdate)
4898            throws DatabaseException {
4899
4900            PrimaryIndex<Integer JavaDoc,ConvertExample4_Entity>
4901                index = store.getPrimaryIndex
4902                    (Integer JavaDoc.class,
4903                     ConvertExample4_Entity.class);
4904            ConvertExample4_Entity obj = index.get(99);
4905            TestCase.assertNotNull(obj);
4906            TestCase.assertEquals(99, obj.key);
4907            TestCase.assertNotNull(obj.embed);
4908            TestCase.assertEquals("name", obj.embed.name);
4909
4910            if (doUpdate) {
4911                index.put(obj);
4912            }
4913        }
4914
4915        @Override JavaDoc
4916        void copyRawObjects(RawStore rawStore, EntityStore newStore)
4917            throws DatabaseException {
4918
4919            PrimaryIndex<Integer JavaDoc,ConvertExample4_Entity>
4920                index = newStore.getPrimaryIndex
4921                    (Integer JavaDoc.class,
4922                     ConvertExample4_Entity.class);
4923            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4924            index.put((ConvertExample4_Entity)
4925                      newStore.getModel().convertRawObject(raw));
4926        }
4927
4928        @Override JavaDoc
4929        void readRawObjects(RawStore store,
4930                            boolean expectEvolved,
4931                            boolean expectUpdated)
4932            throws DatabaseException {
4933
4934            RawType embedTypeA = store.getModel().getRawType(NAME2);
4935            RawType embedTypeB = store.getModel().getRawType(NAME3);
4936            Object JavaDoc embed;
4937            if (expectEvolved) {
4938                embed = new RawObject(embedTypeA, makeValues(),
4939                        new RawObject
4940                            (embedTypeB, makeValues("name", "name"), null));
4941            } else {
4942                embed = new RawObject(embedTypeA, makeValues("name", "name"),
4943                        new RawObject
4944                            (embedTypeB, makeValues(), null));
4945            }
4946            RawObject obj = readRaw
4947                (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
4948            checkRawFields(obj, "key", 99, "embed", embed);
4949        }
4950    }
4951
4952    @Persistent(version=1)
4953    static class ConvertExample5_Pet {
4954        String JavaDoc name;
4955    }
4956
4957    @Persistent
4958    static class ConvertExample5_Cat extends ConvertExample5_Pet {
4959        int finickyLevel;
4960    }
4961
4962    @Persistent
4963    static class ConvertExample5_Dog extends ConvertExample5_Pet {
4964        double barkVolume;
4965    }
4966
4967    static class ConvertExample5_Conversion implements Conversion {
4968        private transient RawType newPetType;
4969        private transient RawType dogType;
4970        private transient RawType catType;
4971
4972        public void initialize(EntityModel model) {
4973            newPetType = model.getRawType(ConvertExample5_Pet.class.getName());
4974            dogType = model.getRawType(ConvertExample5_Dog.class.getName());
4975            catType = model.getRawType(ConvertExample5_Cat.class.getName());
4976        }
4977
4978        public Object JavaDoc convert(Object JavaDoc fromValue) {
4979            RawObject pet = (RawObject) fromValue;
4980            Map JavaDoc<String JavaDoc,Object JavaDoc> petValues = pet.getValues();
4981            Map JavaDoc<String JavaDoc,Object JavaDoc> subTypeValues = new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
4982            Boolean JavaDoc isCat = (Boolean JavaDoc) petValues.remove("isCatNotDog");
4983            Integer JavaDoc finickyLevel = (Integer JavaDoc) petValues.remove("finickyLevel");
4984            Double JavaDoc barkVolume = (Double JavaDoc) petValues.remove("barkVolume");
4985            RawType newSubType;
4986            if (isCat) {
4987                newSubType = catType;
4988                subTypeValues.put("finickyLevel", finickyLevel);
4989            } else {
4990                newSubType = dogType;
4991                subTypeValues.put("barkVolume", barkVolume);
4992            }
4993            RawObject newPet = new RawObject
4994                (newPetType, petValues, pet.getSuper());
4995            return new RawObject(newSubType, subTypeValues, newPet);
4996        }
4997        
4998        @Override JavaDoc
4999        public boolean equals(Object JavaDoc o) {
5000            return o instanceof ConvertExample5_Conversion;
5001        }
5002    }
5003
5004    @Entity(version=1)
5005    static class ConvertExample5_Entity
5006        extends EvolveCase {
5007
5008        private static final String JavaDoc NAME =
5009            ConvertExample5_Entity.class.getName();
5010        private static final String JavaDoc NAME2 =
5011            ConvertExample5_Pet.class.getName();
5012        private static final String JavaDoc NAME3 =
5013            ConvertExample5_Cat.class.getName();
5014        private static final String JavaDoc NAME4 =
5015            ConvertExample5_Dog.class.getName();
5016
5017        @PrimaryKey
5018        int key;
5019
5020        ConvertExample5_Cat cat;
5021        ConvertExample5_Dog dog;
5022
5023        @Override JavaDoc
5024        Mutations getMutations() {
5025            Mutations m = new Mutations();
5026            Converter converter = new Converter
5027                (ConvertExample5_Pet.class.getName(), 0,
5028                 new ConvertExample5_Conversion());
5029            m.addConverter(converter);
5030            return m;
5031        }
5032
5033        @Override JavaDoc
5034        void checkEvolvedModel(EntityModel model,
5035                               Environment env,
5036                               boolean oldTypesExist) {
5037            checkEntity(true, model, env, NAME, 1, null);
5038            if (oldTypesExist) {
5039                checkVersions(model, NAME, 1, NAME, 0);
5040                checkVersions(model, NAME2, 1, NAME2, 0);
5041            } else {
5042                checkVersions(model, NAME, 1);
5043                checkVersions(model, NAME2, 1);
5044            }
5045            checkVersions(model, NAME3, 0);
5046            checkVersions(model, NAME4, 0);
5047        }
5048
5049        @Override JavaDoc
5050        void readObjects(EntityStore store, boolean doUpdate)
5051            throws DatabaseException {
5052
5053            PrimaryIndex<Integer JavaDoc,ConvertExample5_Entity>
5054                index = store.getPrimaryIndex
5055                    (Integer JavaDoc.class,
5056                     ConvertExample5_Entity.class);
5057            ConvertExample5_Entity obj = index.get(99);
5058            TestCase.assertNotNull(obj);
5059            TestCase.assertEquals(99, obj.key);
5060            TestCase.assertNotNull(obj.cat);
5061            TestCase.assertEquals("Jeffry", obj.cat.name);
5062            TestCase.assertEquals(999, obj.cat.finickyLevel);
5063            TestCase.assertNotNull(obj.dog);
5064            TestCase.assertEquals("Nelson", obj.dog.name);
5065            TestCase.assertEquals(0.01, obj.dog.barkVolume);
5066
5067            if (doUpdate) {
5068                index.put(obj);
5069            }
5070        }
5071
5072        @Override JavaDoc
5073        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5074            throws DatabaseException {
5075
5076            PrimaryIndex<Integer JavaDoc,ConvertExample5_Entity>
5077                index = newStore.getPrimaryIndex
5078                    (Integer JavaDoc.class,
5079                     ConvertExample5_Entity.class);
5080            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5081            index.put((ConvertExample5_Entity)
5082                      newStore.getModel().convertRawObject(raw));
5083        }
5084
5085        @Override JavaDoc
5086        void readRawObjects(RawStore store,
5087                            boolean expectEvolved,
5088                            boolean expectUpdated)
5089            throws DatabaseException {
5090
5091            RawType petType = store.getModel().getRawType(NAME2);
5092            RawObject cat;
5093            RawObject dog;
5094            if (expectEvolved) {
5095                RawType catType = store.getModel().getRawType(NAME3);
5096                RawType dogType = store.getModel().getRawType(NAME4);
5097                cat = new RawObject(catType, makeValues("finickyLevel", 999),
5098                      new RawObject(petType, makeValues("name", "Jeffry"),
5099                                    null));
5100                dog = new RawObject(dogType, makeValues("barkVolume", 0.01),
5101                      new RawObject(petType, makeValues("name", "Nelson"),
5102                                    null));
5103            } else {
5104                cat = new RawObject(petType, makeValues("name", "Jeffry",
5105                                                        "isCatNotDog", true,
5106                                                        "finickyLevel", 999,
5107                                                        "barkVolume", 0.0),
5108                                    null);
5109                dog = new RawObject(petType, makeValues("name", "Nelson",
5110                                                        "isCatNotDog", false,
5111                                                        "finickyLevel", 0,
5112                                                        "barkVolume", 0.01),
5113                                    null);
5114            }
5115            RawObject obj = readRaw
5116                (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5117            checkRawFields(obj, "key", 99, "cat", cat, "dog", dog);
5118        }
5119    }
5120
5121    @Persistent(version=1)
5122    static class AllowFieldAddDelete_Embed {
5123        private String JavaDoc f0 = "0";
5124        private String JavaDoc f2;
5125        private int f3 = 3;
5126        private String JavaDoc f4;
5127        private int f5 = 5;
5128        private String JavaDoc f8 = "8";
5129        private int f9 = 9;
5130    }
5131
5132    @Persistent(version=1)
5133    static class AllowFieldAddDelete_Base
5134        extends EvolveCase {
5135
5136        private String JavaDoc f0 = "0";
5137        private String JavaDoc f2;
5138        private int f3 = 3;
5139        private String JavaDoc f4;
5140        private int f5 = 5;
5141        private String JavaDoc f8 = "8";
5142        private int f9 = 9;
5143    }
5144
5145    @Entity(version=1)
5146    static class AllowFieldAddDelete
5147        extends AllowFieldAddDelete_Base {
5148
5149        private static final String JavaDoc NAME =
5150            AllowFieldAddDelete.class.getName();
5151        private static final String JavaDoc NAME2 =
5152            AllowFieldAddDelete_Base.class.getName();
5153        private static final String JavaDoc NAME3 =
5154            AllowFieldAddDelete_Embed.class.getName();
5155
5156        @PrimaryKey
5157        int key;
5158
5159        AllowFieldAddDelete_Embed embed;
5160
5161        private String JavaDoc f0 = "0";
5162        private String JavaDoc f2;
5163        private int f3 = 3;
5164        private String JavaDoc f4;
5165        private int f5 = 5;
5166        private String JavaDoc f8 = "8";
5167        private int f9 = 9;
5168
5169        @Override JavaDoc
5170        Mutations getMutations() {
5171            Mutations m = new Mutations();
5172            for (String JavaDoc name : new String JavaDoc[] {NAME, NAME2, NAME3}) {
5173                m.addDeleter(new Deleter(name, 0, "f1"));
5174                m.addDeleter(new Deleter(name, 0, "f6"));
5175                m.addDeleter(new Deleter(name, 0, "f7"));
5176            }
5177            return m;
5178        }
5179
5180        @Override JavaDoc
5181        void checkEvolvedModel(EntityModel model,
5182                               Environment env,
5183                               boolean oldTypesExist) {
5184            checkEntity(true, model, env, NAME, 1, null);
5185            if (oldTypesExist) {
5186                checkVersions(model, NAME, 1, NAME, 0);
5187                checkVersions(model, NAME2, 1, NAME2, 0);
5188                checkVersions(model, NAME3, 1, NAME3, 0);
5189            } else {
5190                checkVersions(model, NAME, 1);
5191                checkVersions(model, NAME2, 1);
5192                checkVersions(model, NAME3, 1);
5193            }
5194        }
5195
5196        @Override JavaDoc
5197        void readObjects(EntityStore store, boolean doUpdate)
5198            throws DatabaseException {
5199
5200            PrimaryIndex<Integer JavaDoc,AllowFieldAddDelete>
5201                index = store.getPrimaryIndex
5202                    (Integer JavaDoc.class,
5203                     AllowFieldAddDelete.class);
5204            AllowFieldAddDelete obj = index.get(99);
5205            TestCase.assertNotNull(obj);
5206            TestCase.assertEquals(99, obj.key);
5207            {
5208                AllowFieldAddDelete o = obj;
5209            
5210                TestCase.assertNotNull(o);
5211                TestCase.assertEquals("0", o.f0);
5212                TestCase.assertEquals("2", o.f2);
5213                TestCase.assertEquals(3, o.f3);
5214                TestCase.assertEquals("4", o.f4);
5215                TestCase.assertEquals(5, o.f5);
5216                TestCase.assertEquals("8", o.f8);
5217                TestCase.assertEquals(9, o.f9);
5218            }
5219            {
5220                AllowFieldAddDelete_Base o = (AllowFieldAddDelete_Base) obj;
5221            
5222                TestCase.assertNotNull(o);
5223                TestCase.assertEquals("0", o.f0);
5224                TestCase.assertEquals("2", o.f2);
5225                TestCase.assertEquals(3, o.f3);
5226                TestCase.assertEquals("4", o.f4);
5227                TestCase.assertEquals(5, o.f5);
5228                TestCase.assertEquals("8", o.f8);
5229                TestCase.assertEquals(9, o.f9);
5230            }
5231            {
5232                AllowFieldAddDelete_Embed o = obj.embed;
5233            
5234                TestCase.assertNotNull(o);
5235                TestCase.assertEquals("0", o.f0);
5236                TestCase.assertEquals("2", o.f2);
5237                TestCase.assertEquals(3, o.f3);
5238                TestCase.assertEquals("4", o.f4);
5239                TestCase.assertEquals(5, o.f5);
5240                TestCase.assertEquals("8", o.f8);
5241                TestCase.assertEquals(9, o.f9);
5242            }
5243
5244            if (doUpdate) {
5245                index.put(obj);
5246            }
5247        }
5248
5249        @Override JavaDoc
5250        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5251            throws DatabaseException {
5252
5253            PrimaryIndex<Integer JavaDoc,AllowFieldAddDelete>
5254                index = newStore.getPrimaryIndex
5255                    (Integer JavaDoc.class,
5256                     AllowFieldAddDelete.class);
5257            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5258            index.put((AllowFieldAddDelete)
5259                      newStore.getModel().convertRawObject(raw));
5260        }
5261
5262        static final Object JavaDoc[] fixedFields0 = {
5263            "f1", 1,
5264            "f2", "2",
5265            "f4", "4",
5266            "f6", 6,
5267            "f7", "7",
5268        };
5269
5270        static final Object JavaDoc[] fixedFields1 = {
5271            "f2", "2",
5272            "f4", "4",
5273        };
5274
5275        static final Object JavaDoc[] fixedFields2 = {
5276            "f0", "0",
5277            "f2", "2",
5278            "f3", 3,
5279            "f4", "4",
5280            "f5", 5,
5281            "f8", "8",
5282            "f9", 9,
5283        };
5284
5285        @Override JavaDoc
5286        void readRawObjects(RawStore store,
5287                            boolean expectEvolved,
5288                            boolean expectUpdated)
5289            throws DatabaseException {
5290
5291            RawType baseType = store.getModel().getRawType(NAME2);
5292            RawType embedType = store.getModel().getRawType(NAME3);
5293
5294            Object JavaDoc[] ff;
5295            if (expectEvolved) {
5296                if (expectUpdated) {
5297                    ff = fixedFields2;
5298                } else {
5299                    ff = fixedFields1;
5300                }
5301            } else {
5302                ff = fixedFields0;
5303            }
5304            RawObject embed = new RawObject(embedType, makeValues(ff), null);
5305            RawObject obj = readRaw
5306                (store, 99, NAME, expectEvolved ? 1 : 0,
5307                            NAME2, expectEvolved ? 1 : 0,
5308                            CASECLS, 0);
5309            checkRaw(obj, ff, "key", 99, "embed", embed);
5310            checkRaw(obj.getSuper(), ff);
5311        }
5312
5313        private void checkRaw(RawObject obj,
5314                              Object JavaDoc[] fixedFields,
5315                              Object JavaDoc... otherFields) {
5316            Object JavaDoc[] allFields =
5317                new Object JavaDoc[otherFields.length + fixedFields.length];
5318            System.arraycopy(otherFields, 0, allFields, 0, otherFields.length);
5319            System.arraycopy(fixedFields, 0, allFields,
5320                             otherFields.length, fixedFields.length);
5321            checkRawFields(obj, allFields);
5322        }
5323    }
5324
5325    static class ProxiedClass {
5326        int data;
5327
5328        ProxiedClass(int data) {
5329            this.data = data;
5330        }
5331    }
5332
5333    @Persistent(version=1, proxyFor=ProxiedClass.class)
5334    static class ProxiedClass_Proxy implements PersistentProxy<ProxiedClass> {
5335        long data;
5336
5337        public void initializeProxy(ProxiedClass o) {
5338            data = o.data;
5339        }
5340
5341        public ProxiedClass convertProxy() {
5342            return new ProxiedClass((int) data);
5343        }
5344    }
5345
5346    @Entity
5347    static class ProxiedClass_Entity
5348        extends EvolveCase {
5349
5350        private static final String JavaDoc NAME =
5351            ProxiedClass_Entity.class.getName();
5352        private static final String JavaDoc NAME2 =
5353            ProxiedClass_Proxy.class.getName();
5354
5355        @PrimaryKey
5356        int key;
5357
5358        ProxiedClass embed;
5359
5360        @Override JavaDoc
5361        void configure(EntityModel model, StoreConfig config) {
5362            model.registerClass(ProxiedClass_Proxy.class);
5363        }
5364
5365        @Override JavaDoc
5366        void checkEvolvedModel(EntityModel model,
5367                               Environment env,
5368                               boolean oldTypesExist) {
5369            checkEntity(true, model, env, NAME, 0, null);
5370            checkVersions(model, NAME, 0);
5371            if (oldTypesExist) {
5372                checkVersions(model, NAME2, 1, NAME2, 0);
5373            } else {
5374                checkVersions(model, NAME2, 1);
5375            }
5376        }
5377
5378        @Override JavaDoc
5379        void readObjects(EntityStore store, boolean doUpdate)
5380            throws DatabaseException {
5381
5382            PrimaryIndex<Integer JavaDoc,ProxiedClass_Entity>
5383                index = store.getPrimaryIndex
5384                    (Integer JavaDoc.class,
5385                     ProxiedClass_Entity.class);
5386            ProxiedClass_Entity obj = index.get(99);
5387            TestCase.assertNotNull(obj);
5388            TestCase.assertEquals(99, obj.key);
5389            TestCase.assertNotNull(obj.embed);
5390            TestCase.assertEquals(88, obj.embed.data);
5391
5392            if (doUpdate) {
5393                index.put(obj);
5394            }
5395        }
5396
5397        @Override JavaDoc
5398        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5399            throws DatabaseException {
5400
5401            PrimaryIndex<Integer JavaDoc,ProxiedClass_Entity>
5402                index = newStore.getPrimaryIndex
5403                    (Integer JavaDoc.class,
5404                     ProxiedClass_Entity.class);
5405            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5406            index.put((ProxiedClass_Entity)
5407                      newStore.getModel().convertRawObject(raw));
5408        }
5409
5410        @Override JavaDoc
5411        void readRawObjects(RawStore store,
5412                            boolean expectEvolved,
5413                            boolean expectUpdated)
5414            throws DatabaseException {
5415
5416            RawType embedType = store.getModel().getRawType(NAME2);
5417            RawObject embed;
5418            if (expectEvolved) {
5419                embed = new RawObject
5420                    (embedType, makeValues("data", 88L), null);
5421            } else {
5422                embed = new RawObject
5423                    (embedType, makeValues("data", 88), null);
5424            }
5425            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5426            checkRawFields(obj, "key", 99, "embed", embed);
5427        }
5428    }
5429
5430    @Persistent(proxyFor=StringBuffer JavaDoc.class)
5431    static class DisallowChangeProxyFor_Proxy2
5432        implements PersistentProxy<StringBuffer JavaDoc> {
5433
5434        String JavaDoc data;
5435
5436        public void initializeProxy(StringBuffer JavaDoc o) {
5437            data = o.toString();
5438        }
5439
5440        public StringBuffer JavaDoc convertProxy() {
5441            return new StringBuffer JavaDoc(data);
5442        }
5443    }
5444
5445    @Persistent(proxyFor=StringBuilder JavaDoc.class)
5446    static class DisallowChangeProxyFor_Proxy
5447        implements PersistentProxy<StringBuilder JavaDoc> {
5448
5449        String JavaDoc data;
5450
5451        public void initializeProxy(StringBuilder JavaDoc o) {
5452            data = o.toString();
5453        }
5454
5455        public StringBuilder JavaDoc convertProxy() {
5456            return new StringBuilder JavaDoc(data);
5457        }
5458    }
5459
5460    @Entity
5461    static class DisallowChangeProxyFor
5462        extends EvolveCase {
5463
5464        @PrimaryKey
5465        int key;
5466
5467        @Override JavaDoc
5468        public String JavaDoc getStoreOpenException() {
5469            return "com.sleepycat.persist.evolve.IncompatibleClassException: Error when evolving class: java.lang.StringBuffer version: 0 to class: java.lang.StringBuffer 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";
5470        }
5471
5472        @Override JavaDoc
5473        void configure(EntityModel model, StoreConfig config) {
5474            model.registerClass(DisallowChangeProxyFor_Proxy.class);
5475            model.registerClass(DisallowChangeProxyFor_Proxy2.class);
5476        }
5477    }
5478
5479    @Persistent
5480    static class DisallowDeleteProxyFor_Proxy {
5481        String JavaDoc data;
5482    }
5483
5484    @Entity
5485    static class DisallowDeleteProxyFor
5486        extends EvolveCase {
5487
5488        @PrimaryKey
5489        int key;
5490
5491        @Override JavaDoc
5492        public String JavaDoc getStoreOpenException() {
5493            return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: java.lang.StringBuffer version: 0 Error: java.lang.IllegalArgumentException: Class is not persistent: java.lang.StringBuffer";
5494        }
5495    }
5496
5497    @Persistent(version=1)
5498    static class ArrayNameChange_Component_Renamed {
5499
5500        long data;
5501    }
5502
5503    @Entity
5504    static class ArrayNameChange_Entity
5505        extends EvolveCase {
5506
5507        private static final String JavaDoc NAME =
5508            ArrayNameChange_Entity.class.getName();
5509        private static final String JavaDoc NAME2 =
5510            ArrayNameChange_Component_Renamed.class.getName();
5511        private static final String JavaDoc NAME3 =
5512            PREFIX + "ArrayNameChange_Component";
5513
5514        @PrimaryKey
5515        int key;
5516
5517        ArrayNameChange_Component_Renamed[] embed;
5518        ArrayNameChange_Component_Renamed embed2;
5519
5520        @Override JavaDoc
5521        Mutations getMutations() {
5522            Mutations m = new Mutations();
5523            m.addRenamer(new Renamer(NAME3, 0, NAME2));
5524            return m;
5525        }
5526
5527        @Override JavaDoc
5528        void checkEvolvedModel(EntityModel model,
5529                               Environment env,
5530                               boolean oldTypesExist) {
5531            checkEntity(true, model, env, NAME, 0, null);
5532            checkVersions(model, NAME, 0);
5533            if (oldTypesExist) {
5534                checkVersions(model, NAME2, 1, NAME3, 0);
5535            } else {
5536                checkVersions(model, NAME2, 1);
5537            }
5538        }
5539
5540        @Override JavaDoc
5541        void readObjects(EntityStore store, boolean doUpdate)
5542            throws DatabaseException {
5543
5544            PrimaryIndex<Integer JavaDoc,ArrayNameChange_Entity>
5545                index = store.getPrimaryIndex
5546                    (Integer JavaDoc.class,
5547                     ArrayNameChange_Entity.class);
5548            ArrayNameChange_Entity obj = index.get(99);
5549            TestCase.assertNotNull(obj);
5550            TestCase.assertEquals(99, obj.key);
5551            TestCase.assertNotNull(obj.embed);
5552            TestCase.assertEquals(1, obj.embed.length);
5553            TestCase.assertEquals(88L, obj.embed[0].data);
5554            TestCase.assertSame(obj.embed2, obj.embed[0]);
5555
5556            if (doUpdate) {
5557                index.put(obj);
5558            }
5559        }
5560
5561        @Override JavaDoc
5562        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5563            throws DatabaseException {
5564
5565            PrimaryIndex<Integer JavaDoc,ArrayNameChange_Entity>
5566                index = newStore.getPrimaryIndex
5567                    (Integer JavaDoc.class,
5568                     ArrayNameChange_Entity.class);
5569            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5570            index.put((ArrayNameChange_Entity)
5571                      newStore.getModel().convertRawObject(raw));
5572        }
5573
5574        @Override JavaDoc
5575        void readRawObjects(RawStore store,
5576                            boolean expectEvolved,
5577                            boolean expectUpdated)
5578            throws DatabaseException {
5579
5580            String JavaDoc compTypeName = expectEvolved ? NAME2 : NAME3;
5581            String JavaDoc arrayTypeName = "[L" + compTypeName + ';';
5582            RawType compType = store.getModel().getRawType(compTypeName);
5583            RawType arrayType = store.getModel().getRawType(arrayTypeName);
5584            RawObject embed2;
5585            if (expectEvolved) {
5586                embed2 = new RawObject
5587                    (compType, makeValues("data", 88L), null);
5588            } else {
5589                embed2 = new RawObject
5590                    (compType, makeValues("data", 88), null);
5591            }
5592            RawObject embed = new RawObject
5593                (arrayType, new Object JavaDoc[] { embed2 });
5594            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5595            checkRawFields(obj, "key", 99, "embed", embed, "embed2", embed2);
5596        }
5597    }
5598
5599    enum AddEnumConstant_Enum {
5600        A, B, C;
5601    }
5602
5603    @Entity(version=1)
5604    static class AddEnumConstant_Entity
5605        extends EvolveCase {
5606
5607        private static final String JavaDoc NAME =
5608            AddEnumConstant_Entity.class.getName();
5609        private static final String JavaDoc NAME2 =
5610            AddEnumConstant_Enum.class.getName();
5611
5612        @PrimaryKey
5613        int key;
5614
5615        AddEnumConstant_Enum e1;
5616        AddEnumConstant_Enum e2;
5617        AddEnumConstant_Enum e3 = AddEnumConstant_Enum.C;
5618
5619        @Override JavaDoc
5620        void checkEvolvedModel(EntityModel model,
5621                               Environment env,
5622                               boolean oldTypesExist) {
5623            checkEntity(true, model, env, NAME, 1, null);
5624            if (oldTypesExist) {
5625                checkVersions(model, NAME, 1, NAME, 0);
5626                checkVersions(model, NAME2, 0, NAME2, 0);
5627            } else {
5628                checkVersions(model, NAME, 1);
5629                checkVersions(model, NAME2, 0);
5630            }
5631        }
5632
5633        @Override JavaDoc
5634        void readObjects(EntityStore store, boolean doUpdate)
5635            throws DatabaseException {
5636
5637            PrimaryIndex<Integer JavaDoc,AddEnumConstant_Entity>
5638                index = store.getPrimaryIndex
5639                    (Integer JavaDoc.class,
5640                     AddEnumConstant_Entity.class);
5641            AddEnumConstant_Entity obj = index.get(99);
5642            TestCase.assertNotNull(obj);
5643            TestCase.assertEquals(99, obj.key);
5644            TestCase.assertSame(AddEnumConstant_Enum.A, obj.e1);
5645            TestCase.assertSame(AddEnumConstant_Enum.B, obj.e2);
5646            TestCase.assertSame(AddEnumConstant_Enum.C, obj.e3);
5647
5648            if (doUpdate) {
5649                index.put(obj);
5650            }
5651        }
5652
5653        @Override JavaDoc
5654        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5655            throws DatabaseException {
5656
5657            PrimaryIndex<Integer JavaDoc,AddEnumConstant_Entity>
5658                index = newStore.getPrimaryIndex
5659                    (Integer JavaDoc.class,
5660                     AddEnumConstant_Entity.class);
5661            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5662            index.put((AddEnumConstant_Entity)
5663                      newStore.getModel().convertRawObject(raw));
5664        }
5665
5666        @Override JavaDoc
5667        void readRawObjects(RawStore store,
5668                            boolean expectEvolved,
5669                            boolean expectUpdated)
5670            throws DatabaseException {
5671
5672            RawObject obj = readRaw
5673                (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5674            RawType enumType = store.getModel().getRawType(NAME2);
5675            if (expectUpdated) {
5676                checkRawFields(obj, "key", 99,
5677                               "e1", new RawObject(enumType, "A"),
5678                               "e2", new RawObject(enumType, "B"),
5679                               "e3", new RawObject(enumType, "C"));
5680            } else {
5681                checkRawFields(obj, "key", 99,
5682                               "e1", new RawObject(enumType, "A"),
5683                               "e2", new RawObject(enumType, "B"));
5684            }
5685        }
5686    }
5687
5688    enum DeleteEnumConstant_Enum {
5689        A, C;
5690    }
5691
5692    /**
5693     * For now we don't allow deleting enum values. This test case has code
5694     * for testing conversions, for when we add versioning to enums.
5695     */

5696    @Entity
5697    static class DeleteEnumConstant_NoMutation
5698        extends EvolveCase {
5699
5700        private static final String JavaDoc NAME =
5701            DeleteEnumConstant_NoMutation.class.getName();
5702        private static final String JavaDoc NAME2 =
5703            DeleteEnumConstant_Enum.class.getName();
5704
5705        @PrimaryKey
5706        int key;
5707
5708        DeleteEnumConstant_Enum e1;
5709        DeleteEnumConstant_Enum e2;
5710        DeleteEnumConstant_Enum e3;
5711
5712        @Override JavaDoc
5713        public String JavaDoc getStoreOpenException() {
5714            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]";
5715        }
5716
5717            /*
5718            Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 Error: Converter is required when a value is removed from an enum: [B]
5719            */

5720
5721        /*
5722        @Override
5723        Mutations getMutations() {
5724            Mutations m = new Mutations();
5725            Converter converter = new Converter(NAME2, 0, new MyConversion());
5726            m.addConverter(converter);
5727            return m;
5728        }
5729        */

5730
5731        static class MyConversion implements Conversion {
5732
5733            transient RawType newType;
5734
5735            public void initialize(EntityModel model) {
5736                newType = model.getRawType(NAME2);
5737                TestCase.assertNotNull(newType);
5738            }
5739
5740            public Object JavaDoc convert(Object JavaDoc fromValue) {
5741                TestCase.assertNotNull(newType);
5742                RawObject obj = (RawObject) fromValue;
5743                String JavaDoc val = obj.getEnum();
5744                TestCase.assertNotNull(val);
5745                if ("B".equals(val)) {
5746                    val = "C";
5747                }
5748                return new RawObject(newType, val);
5749            }
5750
5751            @Override JavaDoc
5752            public boolean equals(Object JavaDoc other) {
5753                return other instanceof MyConversion;
5754            }
5755        }
5756
5757        @Override JavaDoc
5758        void checkEvolvedModel(EntityModel model,
5759                               Environment env,
5760                               boolean oldTypesExist) {
5761            checkEntity(true, model, env, NAME, 0, null);
5762            checkVersions(model, NAME, 0);
5763            if (oldTypesExist) {
5764                checkVersions(model, NAME2, 0, NAME2, 0);
5765            } else {
5766                checkVersions(model, NAME2, 0);
5767            }
5768        }
5769
5770        @Override JavaDoc
5771        void readObjects(EntityStore store, boolean doUpdate)
5772            throws DatabaseException {
5773
5774            PrimaryIndex<Integer JavaDoc,DeleteEnumConstant_NoMutation>
5775                index = store.getPrimaryIndex
5776                    (Integer JavaDoc.class,
5777                     DeleteEnumConstant_NoMutation.class);
5778            DeleteEnumConstant_NoMutation obj = index.get(99);
5779            TestCase.assertNotNull(obj);
5780            TestCase.assertEquals(99, obj.key);
5781            TestCase.assertSame(DeleteEnumConstant_Enum.A, obj.e1);
5782            TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e2);
5783            TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e3);
5784
5785            if (doUpdate) {
5786                index.put(obj);
5787            }
5788        }
5789
5790        @Override JavaDoc
5791        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5792            throws DatabaseException {
5793
5794            PrimaryIndex<Integer JavaDoc,DeleteEnumConstant_NoMutation>
5795                index = newStore.getPrimaryIndex
5796                    (Integer JavaDoc.class,
5797                     DeleteEnumConstant_NoMutation.class);
5798            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5799            index.put((DeleteEnumConstant_NoMutation)
5800                      newStore.getModel().convertRawObject(raw));
5801        }
5802
5803        @Override JavaDoc
5804        void readRawObjects(RawStore store,
5805                            boolean expectEvolved,
5806                            boolean expectUpdated)
5807            throws DatabaseException {
5808
5809            RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5810            RawType enumType = store.getModel().getRawType(NAME2);
5811            if (expectEvolved) {
5812                checkRawFields(obj, "key", 99,
5813                               "e1", new RawObject(enumType, "A"),
5814                               "e2", new RawObject(enumType, "C"),
5815                               "e3", new RawObject(enumType, "C"));
5816            } else {
5817                checkRawFields(obj, "key", 99,
5818                               "e1", new RawObject(enumType, "A"),
5819                               "e2", new RawObject(enumType, "B"),
5820                               "e3", new RawObject(enumType, "C"));
5821            }
5822        }
5823    }
5824
5825    @Entity
5826    static class DisallowChangeKeyRelate
5827        extends EvolveCase {
5828
5829        private static final String JavaDoc NAME =
5830            DisallowChangeKeyRelate.class.getName();
5831
5832        @PrimaryKey
5833        int key;
5834
5835        @SecondaryKey(relate=MANY_TO_ONE)
5836        int skey;
5837
5838        @Override JavaDoc
5839        public String JavaDoc getStoreOpenException() {
5840            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";
5841        }
5842    }
5843
5844    @Entity(version=1)
5845    static class AllowChangeKeyMetadata
5846        extends EvolveCase {
5847
5848        private static final String JavaDoc NAME =
5849            AllowChangeKeyMetadata.class.getName();
5850
5851        private transient boolean updated;
5852
5853        @PrimaryKey
5854        int key;
5855
5856        /*
5857         * Combined fields from version 0 and 1:
5858         * addAnnotation = 88;
5859         * dropField = 77;
5860         * dropAnnotation = 66;
5861         * addField = 55;
5862         * aa = 33;
5863         * ff = 22;
5864         */

5865
5866        int aa;
5867
5868        @SecondaryKey(relate=ONE_TO_ONE)
5869        int addAnnotation;
5870
5871        int dropAnnotation;
5872
5873        @SecondaryKey(relate=ONE_TO_ONE)
5874        Integer JavaDoc addField;
5875
5876        int ff;
5877
5878        @Override JavaDoc
5879        Mutations getMutations() {
5880            Mutations m = new Mutations();
5881            m.addDeleter(new Deleter(NAME, 0, "dropField"));
5882            return m;
5883        }
5884
5885        @Override JavaDoc
5886        void checkEvolvedModel(EntityModel model,
5887                               Environment env,
5888                               boolean oldTypesExist) {
5889            checkEntity(true, model, env, NAME, 1, null);
5890            if (oldTypesExist) {
5891                checkVersions(model, NAME, 1, NAME, 0);
5892            } else {
5893                checkVersions(model, NAME, 1);
5894            }
5895        }
5896
5897        @Override JavaDoc
5898        void readObjects(EntityStore store, boolean doUpdate)
5899            throws DatabaseException {
5900
5901            PrimaryIndex<Integer JavaDoc,AllowChangeKeyMetadata>
5902                index = store.getPrimaryIndex
5903                    (Integer JavaDoc.class,
5904                     AllowChangeKeyMetadata.class);
5905            AllowChangeKeyMetadata obj = index.get(99);
5906            checkValues(obj);
5907
5908            checkValues(store.getSecondaryIndex
5909                (index, Integer JavaDoc.class, "addAnnotation").get(88));
5910            if (updated) {
5911                checkValues(store.getSecondaryIndex
5912                    (index, Integer JavaDoc.class, "addField").get(55));
5913            } else {
5914                TestCase.assertNull(store.getSecondaryIndex
5915                    (index, Integer JavaDoc.class, "addField").get(55));
5916            }
5917
5918            if (doUpdate) {
5919                obj.addField = 55;
5920                index.put(obj);
5921                updated = true;
5922                checkValues(store.getSecondaryIndex
5923                    (index, Integer JavaDoc.class, "addAnnotation").get(88));
5924                checkValues(store.getSecondaryIndex
5925                    (index, Integer JavaDoc.class, "addField").get(55));
5926            }
5927        }
5928
5929        @Override JavaDoc
5930        void copyRawObjects(RawStore rawStore, EntityStore newStore)
5931            throws DatabaseException {
5932
5933            PrimaryIndex<Integer JavaDoc,AllowChangeKeyMetadata>
5934                index = newStore.getPrimaryIndex
5935                    (Integer JavaDoc.class,
5936                     AllowChangeKeyMetadata.class);
5937            RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5938            index.put((AllowChangeKeyMetadata)
5939                      newStore.getModel().convertRawObject(raw));
5940        }
5941
5942        private void checkValues(AllowChangeKeyMetadata obj) {
5943            TestCase.assertNotNull(obj);
5944            TestCase.assertEquals(99, obj.key);
5945            TestCase.assertEquals(88, obj.addAnnotation);
5946            TestCase.assertEquals(66, obj.dropAnnotation);
5947            TestCase.assertEquals(33, obj.aa);
5948            TestCase.assertEquals(22, obj.ff);
5949            if (updated) {
5950                TestCase.assertEquals(Integer.valueOf(55), obj.addField);
5951            } else {
5952                TestCase.assertNull(obj.addField);
5953            }
5954        }
5955
5956        @Override JavaDoc
5957        void readRawObjects(RawStore store,
5958                            boolean expectEvolved,
5959                            boolean expectUpdated)
5960            throws DatabaseException {
5961
5962            RawObject obj = readRaw
5963                (store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0);
5964            if (expectUpdated) {
5965                checkRawFields(obj, "key", 99,
5966                               "addAnnotation", 88,
5967                               "dropAnnotation", 66,
5968                               "addField", 55,
5969                               "aa", 33,
5970                               "ff", 22);
5971            } else if (expectEvolved) {
5972                checkRawFields(obj, "key", 99,
5973                               "addAnnotation", 88,
5974                               "dropAnnotation", 66,
5975                               "aa", 33,
5976                               "ff", 22);
5977            } else {
5978                checkRawFields(obj, "key", 99,
5979                               "addAnnotation", 88,
5980                               "dropField", 77,
5981                               "dropAnnotation", 66,
5982                               "aa", 33,
5983                               "ff", 22);
5984            }
5985            Environment env = store.getEnvironment();
5986            assertDbExists(expectEvolved, env, NAME, "addAnnotation");
5987            assertDbExists(expectEvolved, env, NAME, "addField");
5988            assertDbExists(!expectEvolved, env, NAME, "dropField");
5989            assertDbExists(!expectEvolved, env, NAME, "dropAnnotation");
5990        }
5991    }
5992}
5993
Popular Tags