1 10 11 package com.triactive.jdo.model; 12 13 import javax.jdo.spi.JDOImplHelper; 14 import javax.jdo.spi.PersistenceCapable; 15 16 17 27 28 public class ClassMetaDataFlagMismatchException extends ClassMetaDataMismatchException 29 { 30 38 39 public ClassMetaDataFlagMismatchException(Class clazz, int fieldNumber, byte expectedFlag, byte actualFlag) 40 { 41 super(clazz, " field #" + fieldNumber + " (" + getFieldName(clazz, fieldNumber) + ") has flag " + 42 getFlagName(actualFlag) + " but the metadata indicates it should be " + getFlagName(expectedFlag)); 43 } 44 45 private static String getFlagName(byte flag) 46 { 47 switch (flag) 48 { 49 case PersistenceCapable.CHECK_WRITE: 50 return "CHECK_WRITE (transient transactional)"; 51 case PersistenceCapable.MEDIATE_WRITE: 52 return "MEDIATE_WRITE (primary key part)"; 53 case PersistenceCapable.CHECK_READ | PersistenceCapable.CHECK_WRITE: 54 return "CHECK_READ | CHECK_WRITE (default fetch group)"; 55 case PersistenceCapable.MEDIATE_READ | PersistenceCapable.MEDIATE_WRITE: 56 return "MEDIATE_READ | MEDIATE_WRITE (non-default fetch group)"; 57 default: 58 return "unknown (" + flag + ")"; 59 } 60 } 61 62 private final static String getFieldName(Class clazz, int fieldNumber) 63 { 64 String [] names = JDOImplHelper.getInstance().getFieldNames(clazz); 65 return (null != names) ? names[fieldNumber] : null; 66 } 67 } 68 | Popular Tags |