/** * Creates an an annotation builder for the specified class metadata * and adds it to list of builders. */ protected AnnotationBuilder addAnnotation( Class<? extends Annotation> annType, QueryResultMapping meta) { AnnotationBuilder ab = newAnnotationBuilder(annType); if (meta == null) return ab; addAnnotation(ab, meta); return ab; }
/** * Creates an an annotation builder for the specified class metadata * and adds it to list of builders. */ protected AnnotationBuilder addAnnotation( Class<? extends Annotation> annType, QueryResultMapping meta) { AnnotationBuilder ab = newAnnotationBuilder(annType); if (meta == null) return ab; addAnnotation(ab, meta); return ab; }
/** * Creates an an annotation builder for the specified class metadata * and adds it to list of builders. */ protected AnnotationBuilder addAnnotation( Class<? extends Annotation> annType, QueryResultMapping meta) { AnnotationBuilder ab = newAnnotationBuilder(annType); if (meta == null) return ab; addAnnotation(ab, meta); return ab; }
/** * Creates an an annotation builder for the specified class metadata * and adds it to list of builders. */ protected AnnotationBuilder addAnnotation( Class<? extends Annotation> annType, QueryResultMapping meta) { AnnotationBuilder ab = newAnnotationBuilder(annType); if (meta == null) return ab; addAnnotation(ab, meta); return ab; }
@Override protected void serializeInheritanceContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); DiscriminatorMappingInfo dinfo = cls.getDiscriminator() .getMappingInfo(); String strat = info.getHierarchyStrategy(); if (null == strat) return; String itypecls = ClassUtil.getClassName(InheritanceType.class); AnnotationBuilder abInheritance = addAnnotation(Inheritance.class, mapping); if (FlatClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".SINGLE_TABLE"); else if (VerticalClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".JOINED"); else if (FullClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".TABLE_PER_CLASS"); if (dinfo.getValue() != null) { AnnotationBuilder abDiscVal = addAnnotation(DiscriminatorValue.class, mapping); abDiscVal.add(null, dinfo.getValue()); } AnnotationBuilder abDiscCol = addAnnotation(DiscriminatorColumn.class, mapping); serializeColumns(dinfo, ColType.DISC, null, abDiscCol, null); }
@Override protected void serializeInheritanceContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); DiscriminatorMappingInfo dinfo = cls.getDiscriminator() .getMappingInfo(); String strat = info.getHierarchyStrategy(); if (null == strat) return; String itypecls = Strings.getClassName(InheritanceType.class); AnnotationBuilder abInheritance = addAnnotation(Inheritance.class, mapping); if (FlatClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".SINGLE_TABLE"); else if (VerticalClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".JOINED"); else if (FullClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".TABLE_PER_CLASS"); if (dinfo.getValue() != null) { AnnotationBuilder abDiscVal = addAnnotation(DiscriminatorValue.class, mapping); abDiscVal.add(null, dinfo.getValue()); } AnnotationBuilder abDiscCol = addAnnotation(DiscriminatorColumn.class, mapping); serializeColumns(dinfo, ColType.DISC, null, abDiscCol, null); }
@Override protected void serializeInheritanceContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); DiscriminatorMappingInfo dinfo = cls.getDiscriminator() .getMappingInfo(); String strat = info.getHierarchyStrategy(); if (null == strat) return; String itypecls = ClassUtil.getClassName(InheritanceType.class); AnnotationBuilder abInheritance = addAnnotation(Inheritance.class, mapping); if (FlatClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".SINGLE_TABLE"); else if (VerticalClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".JOINED"); else if (FullClassStrategy.ALIAS.equals(strat)) abInheritance.add("strategy", itypecls + ".TABLE_PER_CLASS"); if (dinfo.getValue() != null) { AnnotationBuilder abDiscVal = addAnnotation(DiscriminatorValue.class, mapping); abDiscVal.add(null, dinfo.getValue()); } AnnotationBuilder abDiscCol = addAnnotation(DiscriminatorColumn.class, mapping); serializeColumns(dinfo, ColType.DISC, null, abDiscCol, null); }
/** * Serialize the columns in the given mapping info. */ private void serializeColumns(MappingInfo info, ColType type, String secondary, AnnotationBuilder ab, Object meta) { List<Column> cols = (List<Column>) info.getColumns(); if (cols == null) return; AnnotationBuilder abContainer = ab; if (cols.size() > 1) { Class grpType = type.getColumnGroupAnnotationType(); if (null != grpType) { AnnotationBuilder abGrp = newAnnotationBuilder(grpType); if (null == ab) addAnnotation(abGrp, meta); else ab.add(null, abGrp); abContainer = abGrp; } } for (Column col : cols) serializeColumn(col, type, secondary, info.getUnique() != null, abContainer, meta); }
/** * Serialize the columns in the given mapping info. */ private void serializeColumns(MappingInfo info, ColType type, String secondary, AnnotationBuilder ab, Object meta) { List<Column> cols = (List<Column>) info.getColumns(); if (cols == null) return; AnnotationBuilder abContainer = ab; if (cols.size() > 1) { Class grpType = type.getColumnGroupAnnotationType(); if (null != grpType) { AnnotationBuilder abGrp = newAnnotationBuilder(grpType); if (null == ab) addAnnotation(abGrp, meta); else ab.add(null, abGrp); abContainer = abGrp; } } for (Column col : cols) serializeColumn(col, type, secondary, info.getUnique() != null, abContainer, meta); }
/** * Serialize the columns in the given mapping info. */ private void serializeColumns(MappingInfo info, ColType type, String secondary, AnnotationBuilder ab, Object meta) { List<Column> cols = (List<Column>) info.getColumns(); if (cols == null) return; AnnotationBuilder abContainer = ab; if (cols.size() > 1) { Class grpType = type.getColumnGroupAnnotationType(); if (null != grpType) { AnnotationBuilder abGrp = newAnnotationBuilder(grpType); if (null == ab) addAnnotation(abGrp, meta); else ab.add(null, abGrp); abContainer = abGrp; } } for (Column col : cols) serializeColumn(col, type, secondary, info.getUnique() != null, abContainer, meta); }
@Override protected void serializeClassMappingContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); AnnotationBuilder abTable = addAnnotation(Table.class, mapping); serializeTable(info.getTableName(), Strings .getClassName(mapping.getDescribedType()), null, info.getUniques(), abTable); serializeColumns(info, ColType.PK_JOIN, null, abTable, cls); for (String second : info.getSecondaryTableNames()) { AnnotationBuilder abSecTable = addAnnotation(SecondaryTable.class, mapping); serializeTable(second, null, info, null, abSecTable); } }
/** * Serialize the columns in the given mapping info. */ private void serializeColumns(MappingInfo info, ColType type, String secondary, AnnotationBuilder ab, Object meta) { List<Column> cols = (List<Column>) info.getColumns(); if (cols == null) return; AnnotationBuilder abContainer = ab; if (cols.size() > 1) { Class grpType = type.getColumnGroupAnnotationType(); if (null != grpType) { AnnotationBuilder abGrp = newAnnotationBuilder(grpType); if (null == ab) addAnnotation(abGrp, meta); else ab.add(null, abGrp); abContainer = abGrp; } } for (Column col : cols) serializeColumn(col, type, secondary, info.getUnique() != null, abContainer, meta); }
@Override protected void serializeClassMappingContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); AnnotationBuilder abTable = addAnnotation(Table.class, mapping); serializeTable(info.getTableName(), ClassUtil.getClassName(mapping.getDescribedType()), null, info.getUniques(info.getTableName()), abTable); serializeColumns(info, ColType.PK_JOIN, null, abTable, cls); for (String second : info.getSecondaryTableNames()) { AnnotationBuilder abSecTable = addAnnotation(SecondaryTable.class, mapping); serializeTable(second, null, info, info.getUniques(second), abSecTable); } }
@Override protected void serializeClassMappingContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); AnnotationBuilder abTable = addAnnotation(Table.class, mapping); serializeTable(info.getTableName(), ClassUtil.getClassName(mapping.getDescribedType()), null, info.getUniques(info.getTableName()), abTable); serializeColumns(info, ColType.PK_JOIN, null, abTable, cls); for (String second : info.getSecondaryTableNames()) { AnnotationBuilder abSecTable = addAnnotation(SecondaryTable.class, mapping); serializeTable(second, null, info, info.getUniques(second), abSecTable); } }
@Override protected void serializeClassMappingContent(ClassMetaData mapping) { ClassMapping cls = (ClassMapping) mapping; ClassMappingInfo info = cls.getMappingInfo(); AnnotationBuilder abTable = addAnnotation(Table.class, mapping); serializeTable(info.getTableName(), Strings .getClassName(mapping.getDescribedType()), null, info.getUniques(info.getTableName()), abTable); serializeColumns(info, ColType.PK_JOIN, null, abTable, cls); for (String second : info.getSecondaryTableNames()) { AnnotationBuilder abSecTable = addAnnotation(SecondaryTable.class, mapping); serializeTable(second, null, info, info.getUniques(second), abSecTable); } }
AnnotationBuilder ab = addAnnotation(SqlResultSetMapping.class, meta); if (null != clsmeta) addAnnotation(ab, clsmeta); ab.add("name", meta.getName()); for (QueryResultMapping.PCResult pc : meta.getPCResults()) {
AnnotationBuilder ab = addAnnotation(SqlResultSetMapping.class, meta); if (null != clsmeta) addAnnotation(ab, clsmeta); ab.add("name", meta.getName()); for (QueryResultMapping.PCResult pc : meta.getPCResults()) {
AnnotationBuilder ab = addAnnotation(SqlResultSetMapping.class, meta); if (null != clsmeta) addAnnotation(ab, clsmeta); ab.add("name", meta.getName()); for (QueryResultMapping.PCResult pc : meta.getPCResults()) {
@Override protected void serializeSequence(SequenceMetaData meta) { if (SequenceMapping.IMPL_VALUE_TABLE.equals(meta.getSequencePlugin())) { super.serializeSequence(meta); return; } AnnotationBuilder abTblGen = addAnnotation(TableGenerator.class, meta); SequenceMapping seq = (SequenceMapping) meta; abTblGen.add("name", seq.getName()); String table = seq.getTable(); if (table != null) { int dotIdx = table.indexOf('.'); if (dotIdx == -1) abTblGen.add("table", table); else { abTblGen.add("table", table.substring(dotIdx + 1)); abTblGen.add("schema", table.substring(0, dotIdx)); } } if (!StringUtils.isEmpty(seq.getPrimaryKeyColumn())) abTblGen.add("pkColumnName", seq.getPrimaryKeyColumn()); if (!StringUtils.isEmpty(seq.getSequenceColumn())) abTblGen.add("valueColumnName", seq.getSequenceColumn()); if (!StringUtils.isEmpty(seq.getPrimaryKeyValue())) abTblGen.add("pkColumnValue", seq.getPrimaryKeyValue()); if (seq.getAllocate() != 50 && seq.getAllocate() != -1) abTblGen.add("allocationSize", seq.getAllocate() + ""); if (seq.getInitialValue() != 0 && seq.getInitialValue() != -1) abTblGen.add("initialValue", seq.getInitialValue() + ""); }
@Override protected void serializeSequence(SequenceMetaData meta) { if (SequenceMapping.IMPL_VALUE_TABLE.equals(meta.getSequencePlugin())) { super.serializeSequence(meta); return; } AnnotationBuilder abTblGen = addAnnotation(TableGenerator.class, meta); SequenceMapping seq = (SequenceMapping) meta; abTblGen.add("name", seq.getName()); String table = seq.getTable(); if (table != null) { int dotIdx = table.indexOf('.'); if (dotIdx == -1) abTblGen.add("table", table); else { abTblGen.add("table", table.substring(dotIdx + 1)); abTblGen.add("schema", table.substring(0, dotIdx)); } } if (!StringUtil.isEmpty(seq.getPrimaryKeyColumn())) abTblGen.add("pkColumnName", seq.getPrimaryKeyColumn()); if (!StringUtil.isEmpty(seq.getSequenceColumn())) abTblGen.add("valueColumnName", seq.getSequenceColumn()); if (!StringUtil.isEmpty(seq.getPrimaryKeyValue())) abTblGen.add("pkColumnValue", seq.getPrimaryKeyValue()); if (seq.getAllocate() != 50 && seq.getAllocate() != -1) abTblGen.add("allocationSize", seq.getAllocate() + ""); if (seq.getInitialValue() != 0 && seq.getInitialValue() != -1) abTblGen.add("initialValue", seq.getInitialValue() + ""); }