protected int compareUnknown(Object o1, Object o2) { if (!(o1 instanceof QueryResultMapping)) return super.compareUnknown(o1, o2); QueryResultMapping res1 = (QueryResultMapping) o1; QueryResultMapping res2 = (QueryResultMapping) o2; // system scope before class scope Object scope1 = res1.getSourceScope(); Object scope2 = res2.getSourceScope(); if (scope1 == null && scope2 != null) return -1; if (scope1 != null && scope2 == null) return 1; // compare on listing index, or if none/same, use name int listingIndex1 = res1.getListingIndex(); int listingIndex2 = res2.getListingIndex(); if (listingIndex1 != listingIndex2) return listingIndex1 - listingIndex2; return res1.getName ().compareTo (res2.getName ()); } }
private QueryResultMapping addQueryResultMappingInternal(Class cls, String name) { QueryResultMapping res = new QueryResultMapping(name, this); res.setDefiningType(cls); _results.put(getQueryResultKey(res), res); return res; }
/** * Return a unique key for the given mapping. */ private static Object getQueryResultKey(QueryResultMapping res) { if (res == null) return null; return getQueryResultKey(res.getDefiningType(), res.getName()); }
throws SAXException { 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); for (Object col : meta.getColumnResults()) { addAttribute("name", col.toString()); startElement("column-result");
if (null != clsmeta) addAnnotation(ab, clsmeta); ab.add("name", meta.getName()); for (QueryResultMapping.PCResult pc : meta.getPCResults()) { AnnotationBuilder abEntRes = newAnnotationBuilder(EntityResult.class); for (Object col : meta.getColumnResults()) { AnnotationBuilder abColRes = newAnnotationBuilder(ColumnResult.class);
public Object getResultObject() throws SQLException { QueryResultMapping.PCResult[] pcs = _map.getPCResults(); Object[] cols = _map.getColumnResults(); // single object cases if (pcs.length == 0 && cols.length == 1) return _mres.getObject(cols[0], JavaSQLTypes.JDBC_DEFAULT, null); if (pcs.length == 1 && cols.length == 0) return _mres.load(pcs[0], _store, _fetch); // multiple objects Object[] ret = new Object[pcs.length + cols.length]; for (int i = 0; i < pcs.length; i++) ret[i] = _mres.load(pcs[i], _store, _fetch); for (int i = 0; i < cols.length; i++) ret[pcs.length + i] = _mres.getObject(cols[i], JavaSQLTypes.JDBC_DEFAULT, null); return ret; }
result.setSource(getSourceFile(), cm.getDescribedType(), result.SRC_ANNOTATIONS); QueryResultMapping.PCResult entityResult = result.addPCResult (entity.entityClass()); if (!StringUtils.isEmpty(entity.discriminatorColumn())) result.addColumnResult(column.name());
/** * Return the result set mappings for the given scope. */ private List<QueryResultMapping> getQueryResultMappings(ClassMetaData cm) { if (_results == null || _results.isEmpty()) return (List<QueryResultMapping>) Collections.EMPTY_LIST; List<QueryResultMapping> result = null; for (int i = 0; i < _results.size(); i++) { QueryResultMapping element = _results.get(i); if ((cm == null && element.getSourceScope() != null) || (cm != null && element.getSourceScope() != cm.getDescribedType())) continue; if (result == null) result = new ArrayList<QueryResultMapping>(_results.size() - i); result.add(element); } return (result == null) ? (List<QueryResultMapping>) Collections.EMPTY_LIST : result; }
/** * Process a <code>column-result</code> node. */ private boolean startColumnResult(Attributes attrs) throws SAXException { QueryResultMapping parent = (QueryResultMapping) currentElement(); parent.addColumnResult(attrs.getValue("name")); return true; }
/** * Start processing <code>entity-result</code> node. * Pushes the {@link QueryResultMapping.PCResult} * onto the stack as current element. */ private boolean startEntityResult(Attributes attrs) throws SAXException { Class entityClass = classForName(attrs.getValue("entity-class")); String discriminator = attrs.getValue("discriminator-column"); QueryResultMapping parent = (QueryResultMapping) currentElement(); QueryResultMapping.PCResult result = parent.addPCResult(entityClass); if (!StringUtils.isEmpty(discriminator)) result.addMapping(result.DISCRIMINATOR, discriminator); pushElement(result); return true; }
throws SAXException { 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); for (Object col : meta.getColumnResults()) { addAttribute("name", col.toString()); startElement("column-result");
if (null != clsmeta) addAnnotation(ab, clsmeta); ab.add("name", meta.getName()); for (QueryResultMapping.PCResult pc : meta.getPCResults()) { AnnotationBuilder abEntRes = newAnnotationBuilder(EntityResult.class); for (Object col : meta.getColumnResults()) { AnnotationBuilder abColRes = newAnnotationBuilder(ColumnResult.class);
public Object getResultObject() throws SQLException { QueryResultMapping.PCResult[] pcs = _map.getPCResults(); Object[] cols = _map.getColumnResults(); // single object cases if (pcs.length == 0 && cols.length == 1) return _mres.getObject(cols[0], JavaSQLTypes.JDBC_DEFAULT, null); if (pcs.length == 1 && cols.length == 0) return _mres.load(pcs[0], _store, _fetch); // multiple objects Object[] ret = new Object[pcs.length + cols.length]; for (int i = 0; i < pcs.length; i++) ret[i] = _mres.load(pcs[i], _store, _fetch); for (int i = 0; i < cols.length; i++) ret[pcs.length + i] = _mres.getObject(cols[i], JavaSQLTypes.JDBC_DEFAULT, null); return ret; }
result.setSource(getSourceFile(), cm.getDescribedType(), result.SRC_ANNOTATIONS); QueryResultMapping.PCResult entityResult = result.addPCResult (entity.entityClass()); if (!StringUtils.isEmpty(entity.discriminatorColumn())) result.addColumnResult(sName.getName());
/** * Return the result set mappings for the given scope. */ private List<QueryResultMapping> getQueryResultMappings(ClassMetaData cm) { if (_results == null || _results.isEmpty()) return (List<QueryResultMapping>) Collections.EMPTY_LIST; List<QueryResultMapping> result = null; for (int i = 0; i < _results.size(); i++) { QueryResultMapping element = _results.get(i); if ((cm == null && element.getSourceScope() != null) || (cm != null && element.getSourceScope() != cm.getDescribedType())) continue; if (result == null) result = new ArrayList<QueryResultMapping>(_results.size() - i); result.add(element); } return (result == null) ? (List<QueryResultMapping>) Collections.EMPTY_LIST : result; }
/** * Process a <code>column-result</code> node. */ private boolean startColumnResult(Attributes attrs) throws SAXException { QueryResultMapping parent = (QueryResultMapping) currentElement(); parent.addColumnResult(attrs.getValue("name")); return true; }
/** * Start processing <code>entity-result</code> node. * Pushes the {@link QueryResultMapping.PCResult} * onto the stack as current element. */ private boolean startEntityResult(Attributes attrs) throws SAXException { Class<?> entityClass = classForName(attrs.getValue("entity-class")); String discriminator = DBIdentifier.newColumn(attrs.getValue("discriminator-column"), delimit()).getName(); QueryResultMapping parent = (QueryResultMapping) currentElement(); QueryResultMapping.PCResult result = parent.addPCResult(entityClass); if (!StringUtils.isEmpty(discriminator)) result.addMapping(PCResult.DISCRIMINATOR, discriminator); pushElement(result); return true; }
throws SAXException { 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); for (Object col : meta.getColumnResults()) { addAttribute("name", col.toString()); startElement("column-result");
protected int compareUnknown(Object o1, Object o2) { if (!(o1 instanceof QueryResultMapping)) return super.compareUnknown(o1, o2); QueryResultMapping res1 = (QueryResultMapping) o1; QueryResultMapping res2 = (QueryResultMapping) o2; // system scope before class scope Object scope1 = res1.getSourceScope(); Object scope2 = res2.getSourceScope(); if (scope1 == null && scope2 != null) return -1; if (scope1 != null && scope2 == null) return 1; // compare on listing index, or if none/same, use name int listingIndex1 = res1.getListingIndex(); int listingIndex2 = res2.getListingIndex(); if (listingIndex1 != listingIndex2) return listingIndex1 - listingIndex2; return res1.getName ().compareTo (res2.getName ()); } }
if (null != clsmeta) addAnnotation(ab, clsmeta); ab.add("name", meta.getName()); for (QueryResultMapping.PCResult pc : meta.getPCResults()) { AnnotationBuilder abEntRes = newAnnotationBuilder(EntityResult.class); for (Object col : meta.getColumnResults()) { AnnotationBuilder abColRes = newAnnotationBuilder(ColumnResult.class);