Java Examples for org.hibernate.cfg.annotations.reflection.XMLContext.Default
The following java examples will help you to understand the usage of org.hibernate.cfg.annotations.reflection.XMLContext.Default. These source code samples are taken from different open source projects.
Example 1
Project: hibernate-orm-master File: JPAOverriddenAnnotationReader.java View source code |
/*
* The idea is to create annotation proxies for the xml configuration elements. Using this proxy annotations together
* with the {@link JPAMetadataProvider} allows to handle xml configuration the same way as annotation configuration.
*/
private void initAnnotations() {
if (annotations == null) {
XMLContext.Default defaults = xmlContext.getDefault(className);
if (className != null && propertyName == null) {
//is a class
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getPhysicalAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
addIfNotNull(annotationList, getEntity(tree, defaults));
addIfNotNull(annotationList, getMappedSuperclass(tree, defaults));
addIfNotNull(annotationList, getEmbeddable(tree, defaults));
addIfNotNull(annotationList, getTable(tree, defaults));
addIfNotNull(annotationList, getSecondaryTables(tree, defaults));
addIfNotNull(annotationList, getPrimaryKeyJoinColumns(tree, defaults, true));
addIfNotNull(annotationList, getIdClass(tree, defaults));
addIfNotNull(annotationList, getCacheable(tree, defaults));
addIfNotNull(annotationList, getInheritance(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorValue(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorColumn(tree, defaults));
addIfNotNull(annotationList, getSequenceGenerator(tree, defaults));
addIfNotNull(annotationList, getTableGenerator(tree, defaults));
addIfNotNull(annotationList, getNamedQueries(tree, defaults));
addIfNotNull(annotationList, getNamedNativeQueries(tree, defaults));
addIfNotNull(annotationList, getNamedStoredProcedureQueries(tree, defaults));
addIfNotNull(annotationList, getNamedEntityGraphs(tree, defaults));
addIfNotNull(annotationList, getSqlResultSetMappings(tree, defaults));
addIfNotNull(annotationList, getExcludeDefaultListeners(tree, defaults));
addIfNotNull(annotationList, getExcludeSuperclassListeners(tree, defaults));
addIfNotNull(annotationList, getAccessType(tree, defaults));
addIfNotNull(annotationList, getAttributeOverrides(tree, defaults, true));
addIfNotNull(annotationList, getAssociationOverrides(tree, defaults, true));
addIfNotNull(annotationList, getEntityListeners(tree, defaults));
addIfNotNull(annotationList, getConverts(tree, defaults));
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
checkForOrphanProperties(tree);
} else if (//&& propertyName != null ) { //always true but less confusing
className != null) {
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getPhysicalAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
preCalculateElementsForProperty(tree);
Transient transientAnn = getTransient(defaults);
if (transientAnn != null) {
annotationList.add(transientAnn);
} else {
if (defaults.canUseJavaAnnotations()) {
Annotation annotation = getPhysicalAnnotation(Access.class);
addIfNotNull(annotationList, annotation);
}
getId(annotationList, defaults);
getEmbeddedId(annotationList, defaults);
getEmbedded(annotationList, defaults);
getBasic(annotationList, defaults);
getVersion(annotationList, defaults);
getAssociation(ManyToOne.class, annotationList, defaults);
getAssociation(OneToOne.class, annotationList, defaults);
getAssociation(OneToMany.class, annotationList, defaults);
getAssociation(ManyToMany.class, annotationList, defaults);
getAssociation(Any.class, annotationList, defaults);
getAssociation(ManyToAny.class, annotationList, defaults);
getElementCollection(annotationList, defaults);
addIfNotNull(annotationList, getSequenceGenerator(elementsForProperty, defaults));
addIfNotNull(annotationList, getTableGenerator(elementsForProperty, defaults));
addIfNotNull(annotationList, getConvertsForAttribute(elementsForProperty, defaults));
}
processEventAnnotations(annotationList, defaults);
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
} else {
this.annotations = getPhysicalAnnotations();
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
}
}
}
Example 2
Project: hibernate-core-3.6.x-mod-master File: JPAOverridenAnnotationReader.java View source code |
/*
* The idea is to create annotation proxies for the xml configuration elements. Using this proxy annotations together
* with the {@code JPAMetadataprovider} allows to handle xml configuration the same way as annotation configuration.
*/
private void initAnnotations() {
if (annotations == null) {
XMLContext.Default defaults = xmlContext.getDefault(className);
if (className != null && propertyName == null) {
//is a class
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
addIfNotNull(annotationList, getEntity(tree, defaults));
addIfNotNull(annotationList, getMappedSuperclass(tree, defaults));
addIfNotNull(annotationList, getEmbeddable(tree, defaults));
addIfNotNull(annotationList, getTable(tree, defaults));
addIfNotNull(annotationList, getSecondaryTables(tree, defaults));
addIfNotNull(annotationList, getPrimaryKeyJoinColumns(tree, defaults, true));
addIfNotNull(annotationList, getIdClass(tree, defaults));
addIfNotNull(annotationList, getInheritance(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorValue(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorColumn(tree, defaults));
addIfNotNull(annotationList, getSequenceGenerator(tree, defaults));
addIfNotNull(annotationList, getTableGenerator(tree, defaults));
addIfNotNull(annotationList, getNamedQueries(tree, defaults));
addIfNotNull(annotationList, getNamedNativeQueries(tree, defaults));
addIfNotNull(annotationList, getSqlResultSetMappings(tree, defaults));
addIfNotNull(annotationList, getExcludeDefaultListeners(tree, defaults));
addIfNotNull(annotationList, getExcludeSuperclassListeners(tree, defaults));
addIfNotNull(annotationList, getAccessType(tree, defaults));
addIfNotNull(annotationList, getAttributeOverrides(tree, defaults, true));
addIfNotNull(annotationList, getAssociationOverrides(tree, defaults, true));
addIfNotNull(annotationList, getEntityListeners(tree, defaults));
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
checkForOrphanProperties(tree);
} else if (//&& propertyName != null ) { //always true but less confusing
className != null) {
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
preCalculateElementsForProperty(tree);
Transient transientAnn = getTransient(defaults);
if (transientAnn != null) {
annotationList.add(transientAnn);
} else {
if (defaults.canUseJavaAnnotations()) {
Annotation annotation = getJavaAnnotation(Access.class);
addIfNotNull(annotationList, annotation);
}
getId(annotationList, defaults);
getEmbeddedId(annotationList, defaults);
getEmbedded(annotationList, defaults);
getBasic(annotationList, defaults);
getVersion(annotationList, defaults);
getAssociation(ManyToOne.class, annotationList, defaults);
getAssociation(OneToOne.class, annotationList, defaults);
getAssociation(OneToMany.class, annotationList, defaults);
getAssociation(ManyToMany.class, annotationList, defaults);
getElementCollection(annotationList, defaults);
addIfNotNull(annotationList, getSequenceGenerator(elementsForProperty, defaults));
addIfNotNull(annotationList, getTableGenerator(elementsForProperty, defaults));
}
processEventAnnotations(annotationList, defaults);
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
} else {
this.annotations = getJavaAnnotations();
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
}
}
}
Example 3
Project: clinic-softacad-master File: JPAOverriddenAnnotationReader.java View source code |
/*
* The idea is to create annotation proxies for the xml configuration elements. Using this proxy annotations together
* with the {@code JPAMetadataprovider} allows to handle xml configuration the same way as annotation configuration.
*/
private void initAnnotations() {
if (annotations == null) {
XMLContext.Default defaults = xmlContext.getDefault(className);
if (className != null && propertyName == null) {
//is a class
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
addIfNotNull(annotationList, getEntity(tree, defaults));
addIfNotNull(annotationList, getMappedSuperclass(tree, defaults));
addIfNotNull(annotationList, getEmbeddable(tree, defaults));
addIfNotNull(annotationList, getTable(tree, defaults));
addIfNotNull(annotationList, getSecondaryTables(tree, defaults));
addIfNotNull(annotationList, getPrimaryKeyJoinColumns(tree, defaults, true));
addIfNotNull(annotationList, getIdClass(tree, defaults));
addIfNotNull(annotationList, getCacheable(tree, defaults));
addIfNotNull(annotationList, getInheritance(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorValue(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorColumn(tree, defaults));
addIfNotNull(annotationList, getSequenceGenerator(tree, defaults));
addIfNotNull(annotationList, getTableGenerator(tree, defaults));
addIfNotNull(annotationList, getNamedQueries(tree, defaults));
addIfNotNull(annotationList, getNamedNativeQueries(tree, defaults));
addIfNotNull(annotationList, getSqlResultSetMappings(tree, defaults));
addIfNotNull(annotationList, getExcludeDefaultListeners(tree, defaults));
addIfNotNull(annotationList, getExcludeSuperclassListeners(tree, defaults));
addIfNotNull(annotationList, getAccessType(tree, defaults));
addIfNotNull(annotationList, getAttributeOverrides(tree, defaults, true));
addIfNotNull(annotationList, getAssociationOverrides(tree, defaults, true));
addIfNotNull(annotationList, getEntityListeners(tree, defaults));
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
checkForOrphanProperties(tree);
} else if (//&& propertyName != null ) { //always true but less confusing
className != null) {
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
preCalculateElementsForProperty(tree);
Transient transientAnn = getTransient(defaults);
if (transientAnn != null) {
annotationList.add(transientAnn);
} else {
if (defaults.canUseJavaAnnotations()) {
Annotation annotation = getJavaAnnotation(Access.class);
addIfNotNull(annotationList, annotation);
}
getId(annotationList, defaults);
getEmbeddedId(annotationList, defaults);
getEmbedded(annotationList, defaults);
getBasic(annotationList, defaults);
getVersion(annotationList, defaults);
getAssociation(ManyToOne.class, annotationList, defaults);
getAssociation(OneToOne.class, annotationList, defaults);
getAssociation(OneToMany.class, annotationList, defaults);
getAssociation(ManyToMany.class, annotationList, defaults);
getElementCollection(annotationList, defaults);
addIfNotNull(annotationList, getSequenceGenerator(elementsForProperty, defaults));
addIfNotNull(annotationList, getTableGenerator(elementsForProperty, defaults));
}
processEventAnnotations(annotationList, defaults);
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
} else {
this.annotations = getJavaAnnotations();
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
}
}
}
Example 4
Project: hibernate-core-ogm-master File: JPAOverridenAnnotationReader.java View source code |
/*
* The idea is to create annotation proxies for the xml configuration elements. Using this proxy annotations together
* with the {@code JPAMetadataprovider} allows to handle xml configuration the same way as annotation configuration.
*/
private void initAnnotations() {
if (annotations == null) {
XMLContext.Default defaults = xmlContext.getDefault(className);
if (className != null && propertyName == null) {
//is a class
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
addIfNotNull(annotationList, getEntity(tree, defaults));
addIfNotNull(annotationList, getMappedSuperclass(tree, defaults));
addIfNotNull(annotationList, getEmbeddable(tree, defaults));
addIfNotNull(annotationList, getTable(tree, defaults));
addIfNotNull(annotationList, getSecondaryTables(tree, defaults));
addIfNotNull(annotationList, getPrimaryKeyJoinColumns(tree, defaults, true));
addIfNotNull(annotationList, getIdClass(tree, defaults));
addIfNotNull(annotationList, getInheritance(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorValue(tree, defaults));
addIfNotNull(annotationList, getDiscriminatorColumn(tree, defaults));
addIfNotNull(annotationList, getSequenceGenerator(tree, defaults));
addIfNotNull(annotationList, getTableGenerator(tree, defaults));
addIfNotNull(annotationList, getNamedQueries(tree, defaults));
addIfNotNull(annotationList, getNamedNativeQueries(tree, defaults));
addIfNotNull(annotationList, getSqlResultSetMappings(tree, defaults));
addIfNotNull(annotationList, getExcludeDefaultListeners(tree, defaults));
addIfNotNull(annotationList, getExcludeSuperclassListeners(tree, defaults));
addIfNotNull(annotationList, getAccessType(tree, defaults));
addIfNotNull(annotationList, getAttributeOverrides(tree, defaults, true));
addIfNotNull(annotationList, getAssociationOverrides(tree, defaults, true));
addIfNotNull(annotationList, getEntityListeners(tree, defaults));
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
checkForOrphanProperties(tree);
} else if (//&& propertyName != null ) { //always true but less confusing
className != null) {
Element tree = xmlContext.getXMLTree(className);
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>(annotations.length + 5);
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation annotation : annotations) {
if (!annotationToXml.containsKey(annotation.annotationType())) {
//unknown annotations are left over
annotationList.add(annotation);
}
}
preCalculateElementsForProperty(tree);
Transient transientAnn = getTransient(defaults);
if (transientAnn != null) {
annotationList.add(transientAnn);
} else {
if (defaults.canUseJavaAnnotations()) {
Annotation annotation = getJavaAnnotation(Access.class);
addIfNotNull(annotationList, annotation);
}
getId(annotationList, defaults);
getEmbeddedId(annotationList, defaults);
getEmbedded(annotationList, defaults);
getBasic(annotationList, defaults);
getVersion(annotationList, defaults);
getAssociation(ManyToOne.class, annotationList, defaults);
getAssociation(OneToOne.class, annotationList, defaults);
getAssociation(OneToMany.class, annotationList, defaults);
getAssociation(ManyToMany.class, annotationList, defaults);
getElementCollection(annotationList, defaults);
addIfNotNull(annotationList, getSequenceGenerator(elementsForProperty, defaults));
addIfNotNull(annotationList, getTableGenerator(elementsForProperty, defaults));
}
processEventAnnotations(annotationList, defaults);
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
} else {
this.annotations = getJavaAnnotations();
annotationsMap = new HashMap<Class, Annotation>(annotations.length + 5);
for (Annotation ann : this.annotations) {
annotationsMap.put(ann.annotationType(), ann);
}
}
}
}