Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
- import org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer;
- import org.apache.openjpa.persistence.jdbc.AnnotationPersistenceMappingSerializer;
- import org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory;
- public class CustomAnnotationSerializerPersistenceMappingFactory extends PersistenceMappingFactory {
- @Override
- protected AnnotationPersistenceMetaDataSerializer newAnnotationSerializer() {
- AnnotationPersistenceMappingSerializer ser = new CustomEscapedAnnotationPersistenceMappingSerializer((JDBCConfiguration) repos.getConfiguration());
- ser.setSyncMappingInfo(true);
- return ser;
- }
- }
- ======================================================================================
- import java.lang.annotation.Annotation;
- import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
- import org.apache.openjpa.persistence.AnnotationBuilder;
- import org.apache.openjpa.persistence.jdbc.AnnotationPersistenceMappingSerializer;
- public class CustomEscapedAnnotationPersistenceMappingSerializer extends AnnotationPersistenceMappingSerializer {
- public CustomEscapedAnnotationPersistenceMappingSerializer(JDBCConfiguration conf) {
- super(conf);
- }
- @Override
- protected AnnotationBuilder newAnnotationBuilder(Class<? extends Annotation> annType) {
- return new EscapedAnnotationBuilder(annType);
- }
- }
- ======================================================================================
- import java.lang.annotation.Annotation;
- import org.apache.commons.lang3.StringEscapeUtils;
- import org.apache.openjpa.persistence.AnnotationBuilder;
- public class EscapedAnnotationBuilder extends AnnotationBuilder {
- protected EscapedAnnotationBuilder(Class<? extends Annotation> type) {
- super(type);
- }
- @Override
- public AnnotationBuilder add(String key, String val) {
- return super.add(key, StringEscapeUtils.escapeJava(val));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment