Guest User

Bug fix

a guest
Feb 21st, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
  2. import org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer;
  3. import org.apache.openjpa.persistence.jdbc.AnnotationPersistenceMappingSerializer;
  4. import org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory;
  5.  
  6. public class CustomAnnotationSerializerPersistenceMappingFactory extends PersistenceMappingFactory {
  7.     @Override
  8.     protected AnnotationPersistenceMetaDataSerializer newAnnotationSerializer() {
  9.         AnnotationPersistenceMappingSerializer ser = new CustomEscapedAnnotationPersistenceMappingSerializer((JDBCConfiguration) repos.getConfiguration());
  10.         ser.setSyncMappingInfo(true);
  11.         return ser;
  12.     }
  13.  
  14. }
  15.  
  16. ======================================================================================
  17. import java.lang.annotation.Annotation;
  18.  
  19. import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
  20. import org.apache.openjpa.persistence.AnnotationBuilder;
  21. import org.apache.openjpa.persistence.jdbc.AnnotationPersistenceMappingSerializer;
  22.  
  23. public class CustomEscapedAnnotationPersistenceMappingSerializer extends AnnotationPersistenceMappingSerializer {
  24.  
  25.     public CustomEscapedAnnotationPersistenceMappingSerializer(JDBCConfiguration conf) {
  26.         super(conf);
  27.     }
  28.  
  29.     @Override
  30.     protected AnnotationBuilder newAnnotationBuilder(Class<? extends Annotation> annType) {
  31.         return new EscapedAnnotationBuilder(annType);
  32.     }
  33.  
  34. }
  35.  
  36. ======================================================================================
  37. import java.lang.annotation.Annotation;
  38.  
  39. import org.apache.commons.lang3.StringEscapeUtils;
  40. import org.apache.openjpa.persistence.AnnotationBuilder;
  41.  
  42. public class EscapedAnnotationBuilder extends AnnotationBuilder {
  43.  
  44.     protected EscapedAnnotationBuilder(Class<? extends Annotation> type) {
  45.         super(type);
  46.     }
  47.  
  48.     @Override
  49.     public AnnotationBuilder add(String key, String val) {
  50.         return super.add(key, StringEscapeUtils.escapeJava(val));
  51.     }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment