protected XMLPersistenceMetaDataSerializer newXMLSerializer() { XMLPersistenceMappingSerializer ser = new XMLPersistenceMappingSerializer((JDBCConfiguration) repos.getConfiguration()); ser.setSyncMappingInfo(true); return ser; } }
private void serializeUniqueConstraint(Unique unique) throws SAXException { if (StringUtils.isNotEmpty(unique.getName())) { addAttribute("name", unique.getName()); } startElement("unique-constraint"); Column[] columns = unique.getColumns(); for (Column column:columns) { startElement("column-name"); addText(column.getName()); endElement("column-name"); } endElement("unique-constraint"); }
@Override protected void addSystemMappingElements(Collection toSerialize) { if (isQueryMode()) toSerialize.addAll(getQueryResultMappings(null)); }
@Override protected void serializeQueryMappings(ClassMetaData meta) throws SAXException { for (QueryResultMapping res : getQueryResultMappings(meta)) serializeQueryResultMapping(res); }
private void serializeUniqueConstraint(Unique unique) throws SAXException { startElement("unique-constraint"); Column[] columns = unique.getColumns(); for (Column column:columns) { startElement("column-name"); addText(column.getName()); endElement("column-name"); } endElement("unique-constraint"); }
case ONE_ONE: case MANY_ONE: serializeColumns(field.getValueInfo(), ColType.JOIN, field.getMappingInfo().getTableName()); return; if (field.getMappingInfo().getJoinDirection() == MappingInfo.JOIN_NONE) { serializeColumns(field.getElementMapping().getValueInfo(), ColType.JOIN, null); return; int index = table.indexOf('.'); if (index < 0) addAttribute("name", table); else { addAttribute("schema", table.substring(0, index)); addAttribute("name", table.substring(index + 1)); startElement("join-table"); serializeColumns(field.getMappingInfo(), ColType.JOIN, null); serializeColumns(field.getElementMapping().getValueInfo(), ColType.INVERSE, null); endElement("join-table"); serializeColumns(field.getValueInfo(), ColType.COL, field.getMappingInfo().getTableName()); if (strategy == PersistenceStrategy.BASIC && isLob(field)) {
int index = table.indexOf('.'); if (index < 0) addAttribute("name", table); else { addAttribute("schema", table.substring(0, index)); addAttribute("name", table.substring(index + 1)); startElement(elementName); if (cols != null) { for (Column col : cols) serializeColumn(col, ColType.PK_JOIN, null, false); serializeUniqueConstraint(unique); endElement(elementName);
if (!getSerializeAnnotations() && meta.getSourceType() == meta.SRC_ANNOTATIONS) return; addAttribute("name", meta.getName()); startElement("sql-result-set-mapping"); for (QueryResultMapping.PCResult pc : meta.getPCResults()) { addAttribute("entity-class", pc.getCandidateType().getName()); Object discrim = pc.getMapping(pc.DISCRIMINATOR); if (discrim != null) addAttribute("discriminator-column", discrim.toString()); startElement("entity-result"); for (String path : pc.getMappingPaths()) { addAttribute("name", path); addAttribute("column", pc.getMapping(path).toString()); startElement("field-result"); endElement("field-result"); endElement("entity-result"); addAttribute("name", col.toString()); startElement("column-result"); endElement("column-result"); endElement("sql-result-set-mapping");
throws SAXException { if (col.getName() != null) addAttribute("name", col.getName()); if (col.getTypeName() != null) addAttribute("column-definition", col.getTypeName()); if (col.getTarget() != null && (type == ColType.JOIN || type == ColType.INVERSE || type == ColType.PK_JOIN)) addAttribute("referenced-column-name", col.getTarget()); if (type == ColType.COL || type == ColType.JOIN || type == ColType.PK_JOIN) { if (unique) addAttribute("unique", "true"); if (col.isNotNull()) addAttribute("nullable", "false"); if (col.getFlag(Column.FLAG_UNINSERTABLE)) addAttribute("insertable", "false"); if (col.getFlag(Column.FLAG_UNUPDATABLE)) addAttribute("updatable", "false"); if (secondary != null) addAttribute("table", secondary); addAttribute("length", col.getSize() + ""); if (col.getDecimalDigits() != 0) addAttribute("scale", col.getDecimalDigits() + ""); if (type != ColType.COL || getAttributes().getLength() > 0) { String name = col.getFlag(Column.FLAG_PK_JOIN) ? _names .get(ColType.PK_JOIN) : _names.get(type);
/** * Serialize order column. */ protected void serializeOrderColumn(FieldMetaData fmd) throws SAXException { FieldMapping field = (FieldMapping) fmd; Column orderCol = field.getOrderColumn(); if (orderCol != null) { if (orderCol.getName() != null) addAttribute("name", orderCol.getName()); if (orderCol.isNotNull()) addAttribute("nullable", "false"); if (orderCol.getFlag(Column.FLAG_UNINSERTABLE)) addAttribute("insertable", "false"); if (orderCol.getFlag(Column.FLAG_UNUPDATABLE)) addAttribute("updatable", "false"); if (orderCol.getTypeName() != null) addAttribute("column-definition", orderCol.getTypeName()); startElement("order-column"); endElement("order-column"); } }
@Override public void addAll(MetaDataRepository repos) { super.addAll(repos); for (QueryResultMapping res : ((MappingRepository) repos) .getQueryResultMappings()) addQueryResultMapping(res); }
/** * Return field's temporal type. */ private TemporalType getTemporal(FieldMapping field) { if (field.getDeclaredTypeCode() != JavaTypes.DATE && field.getDeclaredTypeCode() != JavaTypes.CALENDAR) return null; DBDictionary dict = ((JDBCConfiguration) getConfiguration()) .getDBDictionaryInstance(); int def = dict.getJDBCType(field.getTypeCode(), false); for (Column col : (List<Column>) field.getValueInfo().getColumns()) { if (col.getType() == def) continue; switch (col.getType()) { case Types.DATE: return TemporalType.DATE; case Types.TIME: return TemporalType.TIME; case Types.TIMESTAMP: return TemporalType.TIMESTAMP; } } return null; }
case ONE_ONE: case MANY_ONE: serializeColumns(field.getValueInfo(), ColType.JOIN, field.getMappingInfo().getTableName()); return; if (field.getMappingInfo().getJoinDirection() == MappingInfo.JOIN_NONE) { serializeColumns(field.getElementMapping().getValueInfo(), ColType.JOIN, null); return; int index = table.indexOf('.'); if (index < 0) addAttribute("name", table); else { addAttribute("schema", table.substring(0, index)); addAttribute("name", table.substring(index + 1)); startElement("join-table"); serializeColumns(field.getMappingInfo(), ColType.JOIN, null); serializeColumns(field.getElementMapping().getValueInfo(), ColType.INVERSE, null); endElement("join-table"); int index = table.indexOf('.'); if (index < 0) addAttribute("name", table);
int index = table.indexOf('.'); if (index < 0) addAttribute("name", table); else { Map<String, ClassMetaData> classMetaData = getClassMetaData(); Object[] keySet = null; if(classMetaData != null) addAttribute("schema", table.substring(0, index)); addAttribute("name", table.substring(index + 1)); startElement(elementName); if (cols != null) { for (Column col : cols) serializeColumn(col, ColType.PK_JOIN, null, false); serializeUniqueConstraint(unique); endElement(elementName);
if (!getSerializeAnnotations() && meta.getSourceType() == meta.SRC_ANNOTATIONS) return; addAttribute("name", meta.getName()); startElement("sql-result-set-mapping"); for (QueryResultMapping.PCResult pc : meta.getPCResults()) { addAttribute("entity-class", pc.getCandidateType().getName()); Object discrim = pc.getMapping(pc.DISCRIMINATOR); if (discrim != null) addAttribute("discriminator-column", discrim.toString()); startElement("entity-result"); for (String path : pc.getMappingPaths()) { addAttribute("name", path); addAttribute("column", pc.getMapping(path).toString()); startElement("field-result"); endElement("field-result"); endElement("entity-result"); addAttribute("name", col.toString()); startElement("column-result"); endElement("column-result"); endElement("sql-result-set-mapping");
throws SAXException { if (col.getName() != null) addAttribute("name", col.getName()); if (col.getTypeName() != null) addAttribute("column-definition", col.getTypeName()); if (col.getTarget() != null && (type == ColType.JOIN || type == ColType.INVERSE || type == ColType.PK_JOIN)) addAttribute("referenced-column-name", col.getTarget()); if (type == ColType.COL || type == ColType.JOIN || type == ColType.PK_JOIN) { if (unique) addAttribute("unique", "true"); if (col.isNotNull()) addAttribute("nullable", "false"); if (col.getFlag(Column.FLAG_UNINSERTABLE)) addAttribute("insertable", "false"); if (col.getFlag(Column.FLAG_UNUPDATABLE)) addAttribute("updatable", "false"); if (secondary != null) addAttribute("table", secondary); addAttribute("length", col.getSize() + ""); if (col.getDecimalDigits() != 0) addAttribute("scale", col.getDecimalDigits() + ""); if (type != ColType.COL || getAttributes().getLength() > 0) { String name = col.getFlag(Column.FLAG_PK_JOIN) ? _names .get(ColType.PK_JOIN) : _names.get(type);
/** * Serialize order column. */ protected void serializeOrderColumn(FieldMetaData fmd) throws SAXException { FieldMapping field = (FieldMapping) fmd; Column orderCol = field.getOrderColumn(); if (orderCol != null) { if (orderCol.getName() != null) addAttribute("name", orderCol.getName()); if (orderCol.isNotNull()) addAttribute("nullable", "false"); if (orderCol.getFlag(Column.FLAG_UNINSERTABLE)) addAttribute("insertable", "false"); if (orderCol.getFlag(Column.FLAG_UNUPDATABLE)) addAttribute("updatable", "false"); if (orderCol.getTypeName() != null) addAttribute("column-definition", orderCol.getTypeName()); startElement("order-column"); endElement("order-column"); } }
@Override protected void serializeQueryMappings(ClassMetaData meta) throws SAXException { for (QueryResultMapping res : getQueryResultMappings(meta)) serializeQueryResultMapping(res); }
@Override public void addAll(MetaDataRepository repos) { super.addAll(repos); for (QueryResultMapping res : ((MappingRepository) repos) .getQueryResultMappings()) addQueryResultMapping(res); }
/** * Return field's temporal type. */ private TemporalType getTemporal(FieldMapping field) { if (field.getDeclaredTypeCode() != JavaTypes.DATE && field.getDeclaredTypeCode() != JavaTypes.CALENDAR) return null; DBDictionary dict = ((JDBCConfiguration) getConfiguration()) .getDBDictionaryInstance(); int def = dict.getJDBCType(field.getTypeCode(), false); for (Column col : (List<Column>) field.getValueInfo().getColumns()) { if (col.getType() == def) continue; switch (col.getType()) { case Types.DATE: return TemporalType.DATE; case Types.TIME: return TemporalType.TIME; case Types.TIMESTAMP: return TemporalType.TIMESTAMP; } } return null; }