private static PersistenceContext newPersistenceContext ( final String fJndiName , final String fUnitName , final int fCtxType , final List < Property > fCtxProperties ) { return new PersistenceContext ( ) { @ Override public Class < ? extends Annotation > annotationType ( ) { return PersistenceContext . class ; } @ Override public String name ( ) { return fJndiName ; } @ Override public PersistenceProperty [ ] properties ( ) { //TODO not ideal doing this conversion processing here PersistenceProperty [ ] props = new PersistenceProperty [ fCtxProperties . size ( ) ] ; int i = 0 ; for ( Property property : fCtxProperties ) { final String name = property . getName ( ) ; final String value = property . getValue ( ) ; PersistenceProperty prop = new PersistenceProperty ( ) { @ Override public Class < ? extends Annotation > annotationType ( ) { return PersistenceProperty . class ; } @ Override public String name ( ) { return name ; } @ Override public String value ( ) { return value ; } } ; props [ i ++ ] = prop ; } return props ; } @ Override public PersistenceContextType type ( ) { if ( fCtxType == PersistenceContextRef . TYPE_TRANSACTION ) { return PersistenceContextType . TRANSACTION ; } else { return PersistenceContextType . EXTENDED ; } } @ Override public String unitName ( ) { return fUnitName ; } @ Override public String toString ( ) { return "JPA.PersistenceContext(name=" + fJndiName + ", unitName=" + fUnitName + ")" ; } } ; }
This transient PersistenceContext annotation class has no default value . i . e . null is a valid value for some fields .