/** * Adds an @OrderColumn annotation to the specified annotationList if the specified element * contains an order-column sub-element. This should only be the case for element-collection, * many-to-many, or one-to-many associations. */ private void getOrderColumn(List<Annotation> annotationList, Element element) { Element subelement = element != null ? element.element( "order-column" ) : null; if ( subelement != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( OrderColumn.class ); copyStringAttribute( ad, subelement, "name", false ); copyBooleanAttribute( ad, subelement, "nullable" ); copyBooleanAttribute( ad, subelement, "insertable" ); copyBooleanAttribute( ad, subelement, "updatable" ); copyStringAttribute( ad, subelement, "column-definition", false ); annotationList.add( AnnotationFactory.create( ad ) ); } }
private MapKeyJoinColumn[] getMapKeyJoinColumns(Element element) { List<Element> subelements = element != null ? element.elements( "map-key-join-column" ) : null; List<MapKeyJoinColumn> joinColumns = new ArrayList<>(); if ( subelements != null ) { for ( Element subelement : subelements ) { AnnotationDescriptor column = new AnnotationDescriptor( MapKeyJoinColumn.class ); copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false ); copyBooleanAttribute( column, subelement, "unique" ); copyBooleanAttribute( column, subelement, "nullable" ); copyBooleanAttribute( column, subelement, "insertable" ); copyBooleanAttribute( column, subelement, "updatable" ); copyStringAttribute( column, subelement, "column-definition", false ); copyStringAttribute( column, subelement, "table", false ); joinColumns.add( AnnotationFactory.create( column ) ); } } return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] ); }
private JoinColumn[] getJoinColumns(Element element, boolean isInverse) { List<Element> subelements = element != null ? element.elements( isInverse ? "inverse-join-column" : "join-column" ) : null; List<JoinColumn> joinColumns = new ArrayList<>(); if ( subelements != null ) { for ( Element subelement : subelements ) { AnnotationDescriptor column = new AnnotationDescriptor( JoinColumn.class ); copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false ); copyBooleanAttribute( column, subelement, "unique" ); copyBooleanAttribute( column, subelement, "nullable" ); copyBooleanAttribute( column, subelement, "insertable" ); copyBooleanAttribute( column, subelement, "updatable" ); copyStringAttribute( column, subelement, "column-definition", false ); copyStringAttribute( column, subelement, "table", false ); joinColumns.add( AnnotationFactory.create( column ) ); } } return joinColumns.toArray( new JoinColumn[joinColumns.size()] ); }
private void getMapKeyColumn(List<Annotation> annotationList, Element element) { Element subelement = element != null ? element.element( "map-key-column" ) : null; if ( subelement != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyColumn.class ); copyStringAttribute( ad, subelement, "name", false ); copyBooleanAttribute( ad, subelement, "unique" ); copyBooleanAttribute( ad, subelement, "nullable" ); copyBooleanAttribute( ad, subelement, "insertable" ); copyBooleanAttribute( ad, subelement, "updatable" ); copyStringAttribute( ad, subelement, "column-definition", false ); copyStringAttribute( ad, subelement, "table", false ); copyIntegerAttribute( ad, subelement, "length" ); copyIntegerAttribute( ad, subelement, "precision" ); copyIntegerAttribute( ad, subelement, "scale" ); annotationList.add( AnnotationFactory.create( ad ) ); } }
private static void buildIndex(AnnotationDescriptor annotation, Element element){ List indexElementList = element.elements( "index" ); Index[] indexes = new Index[indexElementList.size()]; for(int i=0;i<indexElementList.size();i++){ Element subelement = (Element)indexElementList.get( i ); AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class ); copyStringAttribute( indexAnn, subelement, "name", false ); copyStringAttribute( indexAnn, subelement, "column-list", true ); copyBooleanAttribute( indexAnn, subelement, "unique" ); indexes[i] = AnnotationFactory.create( indexAnn ); } annotation.setValue( "indexes", indexes ); } private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {
public static List<NamedEntityGraph> buildNamedEntityGraph( Element element, XMLContext.Default defaults, ClassLoaderAccess classLoaderAccess) { if ( element == null ) { return new ArrayList<>(); } List<NamedEntityGraph> namedEntityGraphList = new ArrayList<>(); List<Element> namedEntityGraphElements = element.elements( "named-entity-graph" ); for ( Element subElement : namedEntityGraphElements ) { AnnotationDescriptor ann = new AnnotationDescriptor( NamedEntityGraph.class ); copyStringAttribute( ann, subElement, "name", false ); copyBooleanAttribute( ann, subElement, "include-all-attributes" ); bindNamedAttributeNodes( subElement, ann ); List<Element> subgraphNodes = subElement.elements( "subgraph" ); List<Element> subclassSubgraphNodes = subElement.elements( "subclass-subgraph" ); if(!subclassSubgraphNodes.isEmpty()) { subgraphNodes.addAll( subclassSubgraphNodes ); } bindNamedSubgraph( defaults, ann, subgraphNodes, classLoaderAccess ); namedEntityGraphList.add( AnnotationFactory.create( ann ) ); } //TODO return namedEntityGraphList; }
private Column getColumn(Element element, boolean isMandatory, Element current) { //Element subelement = element != null ? element.element( "column" ) : null; if ( element != null ) { AnnotationDescriptor column = new AnnotationDescriptor( Column.class ); copyStringAttribute( column, element, "name", false ); copyBooleanAttribute( column, element, "unique" ); copyBooleanAttribute( column, element, "nullable" ); copyBooleanAttribute( column, element, "insertable" ); copyBooleanAttribute( column, element, "updatable" ); copyStringAttribute( column, element, "column-definition", false ); copyStringAttribute( column, element, "table", false ); copyIntegerAttribute( column, element, "length" ); copyIntegerAttribute( column, element, "precision" ); copyIntegerAttribute( column, element, "scale" ); return (Column) AnnotationFactory.create( column ); } else { if ( isMandatory ) { throw new AnnotationException( current.getPath() + ".column is mandatory. " + SCHEMA_VALIDATION ); } return null; } }
final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class ); copyStringAttribute( convertAnnotationDescriptor, convertElement, "attribute-name", false ); copyBooleanAttribute( convertAnnotationDescriptor, convertElement, "disable-conversion" );
AnnotationDescriptor basic = new AnnotationDescriptor( Basic.class ); getFetchType( basic, element ); copyBooleanAttribute( basic, element, "optional" ); annotationList.add( AnnotationFactory.create( basic ) );
Annotation annotation = getPrimaryKeyJoinColumns( element, defaults, false ); addIfNotNull( annotationList, annotation ); copyBooleanAttribute( ad, element, "optional" ); copyBooleanAttribute( ad, element, "orphan-removal" ); copyStringAttribute( ad, element, "mapped-by", false ); getOrderBy( annotationList, element );
/** * Adds an @OrderColumn annotation to the specified annotationList if the specified element * contains an order-column sub-element. This should only be the case for element-collection, * many-to-many, or one-to-many associations. */ private void getOrderColumn(List<Annotation> annotationList, Element element) { Element subelement = element != null ? element.element( "order-column" ) : null; if ( subelement != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( OrderColumn.class ); copyStringAttribute( ad, subelement, "name", false ); copyBooleanAttribute( ad, subelement, "nullable" ); copyBooleanAttribute( ad, subelement, "insertable" ); copyBooleanAttribute( ad, subelement, "updatable" ); copyStringAttribute( ad, subelement, "column-definition", false ); annotationList.add( AnnotationFactory.create( ad ) ); } }
private MapKeyJoinColumn[] getMapKeyJoinColumns(Element element) { List<Element> subelements = element != null ? element.elements( "map-key-join-column" ) : null; List<MapKeyJoinColumn> joinColumns = new ArrayList<>(); if ( subelements != null ) { for ( Element subelement : subelements ) { AnnotationDescriptor column = new AnnotationDescriptor( MapKeyJoinColumn.class ); copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false ); copyBooleanAttribute( column, subelement, "unique" ); copyBooleanAttribute( column, subelement, "nullable" ); copyBooleanAttribute( column, subelement, "insertable" ); copyBooleanAttribute( column, subelement, "updatable" ); copyStringAttribute( column, subelement, "column-definition", false ); copyStringAttribute( column, subelement, "table", false ); joinColumns.add( AnnotationFactory.create( column ) ); } } return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] ); }
private JoinColumn[] getJoinColumns(Element element, boolean isInverse) { List<Element> subelements = element != null ? element.elements( isInverse ? "inverse-join-column" : "join-column" ) : null; List<JoinColumn> joinColumns = new ArrayList<>(); if ( subelements != null ) { for ( Element subelement : subelements ) { AnnotationDescriptor column = new AnnotationDescriptor( JoinColumn.class ); copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false ); copyBooleanAttribute( column, subelement, "unique" ); copyBooleanAttribute( column, subelement, "nullable" ); copyBooleanAttribute( column, subelement, "insertable" ); copyBooleanAttribute( column, subelement, "updatable" ); copyStringAttribute( column, subelement, "column-definition", false ); copyStringAttribute( column, subelement, "table", false ); joinColumns.add( AnnotationFactory.create( column ) ); } } return joinColumns.toArray( new JoinColumn[joinColumns.size()] ); }
private void getMapKeyColumn(List<Annotation> annotationList, Element element) { Element subelement = element != null ? element.element( "map-key-column" ) : null; if ( subelement != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyColumn.class ); copyStringAttribute( ad, subelement, "name", false ); copyBooleanAttribute( ad, subelement, "unique" ); copyBooleanAttribute( ad, subelement, "nullable" ); copyBooleanAttribute( ad, subelement, "insertable" ); copyBooleanAttribute( ad, subelement, "updatable" ); copyStringAttribute( ad, subelement, "column-definition", false ); copyStringAttribute( ad, subelement, "table", false ); copyIntegerAttribute( ad, subelement, "length" ); copyIntegerAttribute( ad, subelement, "precision" ); copyIntegerAttribute( ad, subelement, "scale" ); annotationList.add( AnnotationFactory.create( ad ) ); } }
private static void buildIndex(AnnotationDescriptor annotation, Element element){ List indexElementList = element.elements( "index" ); Index[] indexes = new Index[indexElementList.size()]; for(int i=0;i<indexElementList.size();i++){ Element subelement = (Element)indexElementList.get( i ); AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class ); copyStringAttribute( indexAnn, subelement, "name", false ); copyStringAttribute( indexAnn, subelement, "column-list", true ); copyBooleanAttribute( indexAnn, subelement, "unique" ); indexes[i] = AnnotationFactory.create( indexAnn ); } annotation.setValue( "indexes", indexes ); } private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {
public static List<NamedEntityGraph> buildNamedEntityGraph( Element element, XMLContext.Default defaults, ClassLoaderAccess classLoaderAccess) { if ( element == null ) { return new ArrayList<>(); } List<NamedEntityGraph> namedEntityGraphList = new ArrayList<>(); List<Element> namedEntityGraphElements = element.elements( "named-entity-graph" ); for ( Element subElement : namedEntityGraphElements ) { AnnotationDescriptor ann = new AnnotationDescriptor( NamedEntityGraph.class ); copyStringAttribute( ann, subElement, "name", false ); copyBooleanAttribute( ann, subElement, "include-all-attributes" ); bindNamedAttributeNodes( subElement, ann ); List<Element> subgraphNodes = subElement.elements( "subgraph" ); List<Element> subclassSubgraphNodes = subElement.elements( "subclass-subgraph" ); if(!subclassSubgraphNodes.isEmpty()) { subgraphNodes.addAll( subclassSubgraphNodes ); } bindNamedSubgraph( defaults, ann, subgraphNodes, classLoaderAccess ); namedEntityGraphList.add( AnnotationFactory.create( ann ) ); } //TODO return namedEntityGraphList; }
private Column getColumn(Element element, boolean isMandatory, Element current) { //Element subelement = element != null ? element.element( "column" ) : null; if ( element != null ) { AnnotationDescriptor column = new AnnotationDescriptor( Column.class ); copyStringAttribute( column, element, "name", false ); copyBooleanAttribute( column, element, "unique" ); copyBooleanAttribute( column, element, "nullable" ); copyBooleanAttribute( column, element, "insertable" ); copyBooleanAttribute( column, element, "updatable" ); copyStringAttribute( column, element, "column-definition", false ); copyStringAttribute( column, element, "table", false ); copyIntegerAttribute( column, element, "length" ); copyIntegerAttribute( column, element, "precision" ); copyIntegerAttribute( column, element, "scale" ); return (Column) AnnotationFactory.create( column ); } else { if ( isMandatory ) { throw new AnnotationException( current.getPath() + ".column is mandatory. " + SCHEMA_VALIDATION ); } return null; } }
final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class ); copyStringAttribute( convertAnnotationDescriptor, convertElement, "attribute-name", false ); copyBooleanAttribute( convertAnnotationDescriptor, convertElement, "disable-conversion" );
AnnotationDescriptor basic = new AnnotationDescriptor( Basic.class ); getFetchType( basic, element ); copyBooleanAttribute( basic, element, "optional" ); annotationList.add( AnnotationFactory.create( basic ) );
Annotation annotation = getPrimaryKeyJoinColumns( element, defaults, false ); addIfNotNull( annotationList, annotation ); copyBooleanAttribute( ad, element, "optional" ); copyBooleanAttribute( ad, element, "orphan-removal" ); copyStringAttribute( ad, element, "mapped-by", false ); getOrderBy( annotationList, element );