List of usage examples for org.apache.ibatis.mapping ResultMapping getProperty
public String getProperty()
From source file:com.github.abel533.mapper.MapperHelper.java
License:Open Source License
/** * Set//from w ww. j ava 2s. c o m * * @param resultMappings * @return */ private Set<String> toPropertySet(List<ResultMapping> resultMappings) { Set<String> propertySet = new HashSet<String>(); for (ResultMapping resultMapping : resultMappings) { propertySet.add(resultMapping.getProperty()); } return propertySet; }
From source file:com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.java
License:Apache License
public Object queryForObject(String id, Object parameterObject, Object userObject) throws SQLException { Object systemObject = queryForObject(id, parameterObject); if (systemObject != null && userObject != null) { MappedStatement ms = configuration.getMappedStatement(id); for (ResultMap rm : ms.getResultMaps()) { for (ResultMapping mapping : rm.getPropertyResultMappings()) { MetaObject metaUserObject = SystemMetaObject.forObject(userObject); MetaObject metaSystemObject = SystemMetaObject.forObject(systemObject); String propName = mapping.getProperty(); if (propName != null) { metaUserObject.setValue(propName, metaSystemObject.getValue(propName)); }//w ww. j a v a2s .co m } } } return userObject; }
From source file:com.playersun.jbf.common.persistence.search.SearchableSqlBuilder.java
License:Apache License
/** * ??ResultMappingcolumn/*from w ww. j ava 2s.c o m*/ * ?column??parentIdcolumnparent_id * @param prop * @param resultMappings * @return */ private String findInResultMapping(String prop, List<ResultMapping> resultMappings) { for (ResultMapping rsm : resultMappings) { if (prop.equals(rsm.getProperty())) { return rsm.getColumn(); } } return prop; }
From source file:das.orm.ORMBackendConnector.java
License:Apache License
public List<BeanPropertyMapping> getBeanPropertiesMapping(Class<?> beanClass) { log.trace(">>> getBeanPropertiesMapping()"); List<BeanPropertyMapping> DAOprops = new ArrayList<BeanPropertyMapping>(); Configuration conf = getConfiguration(); if (conf != null) { ///*from w ww. j av a 2 s. c o m*/ //checkDAOMapperClass(mapperClass, dao); Collection<ResultMap> rmc = conf.getResultMaps(); //log.debug("ResultMaps size="+rmc.size()); Iterator<ResultMap> rmci = rmc.iterator(); while (rmci.hasNext()) { ResultMap rm = rmci.next(); // ID=com.example.server.dao.UserMapper.UserMap, Type=com.example.server.dao.UserDTO log.debug("ResultMap ID=" + rm.getId() + ", Type=" + rm.getType().getName()); // ?, ?? ResultMap ?? beanClass if (isCompatibleMap(rm, beanClass)) { List<ResultMapping> r = rm.getResultMappings(); Iterator<ResultMapping> i2 = r.iterator(); while (i2.hasNext()) { ResultMapping r2 = i2.next(); // ? ?? (?) . // ? ?? ? ? ?? DAOprops.add(new BeanPropertyMapping(r2.getProperty(), r2.getColumn(), r2.getJavaType(), r2.getFlags(), r2.getNotNullColumns())); StringBuilder s = new StringBuilder(); s.append("Column=").append(r2.getColumn()); s.append(", Property=").append(r2.getProperty()); s.append(", JavaType=").append(r2.getJavaType()); s.append(", Flags=["); List<ResultFlag> flags = r2.getFlags(); for (ResultFlag rf : flags) { s.append(rf.name()).append(", "); } s.append("]"); s.append(", NotNullColumns=["); Set<String> nncs = r2.getNotNullColumns(); for (String nnc : nncs) { s.append(nnc).append(", "); } s.append("]"); log.debug(s.toString()); } break; // ?? , ? } } } return DAOprops; }
From source file:fxapp01.orm.ORMBackendConnector.java
License:Apache License
public List<BeanPropertyMapping> getBeanPropertiesMapping(Class beanClass) { log.trace(">>> getDAOProperties()"); List<BeanPropertyMapping> DAOprops = new ArrayList<>(); Configuration conf = getConfiguration(); if (conf != null) { //// w w w.jav a2 s .co m //checkDAOMapperClass(mapperClass, dao); Collection<ResultMap> rmc = conf.getResultMaps(); //log.debug("ResultMaps size="+rmc.size()); Iterator<ResultMap> rmci = rmc.iterator(); while (rmci.hasNext()) { ResultMap rm = rmci.next(); // ID=com.example.server.dao.UserMapper.UserMap, Type=com.example.server.dao.UserDTO log.debug("ResultMap ID=" + rm.getId() + ", Type=" + rm.getType().getName()); // ?, ?? ResultMap ?? beanClass if (isCompatibleMap(rm, beanClass)) { List<ResultMapping> r = rm.getResultMappings(); Iterator<ResultMapping> i2 = r.iterator(); while (i2.hasNext()) { ResultMapping r2 = i2.next(); // ? ?? (?) . // ? ?? ? ? ?? DAOprops.add(new BeanPropertyMapping(r2.getProperty(), r2.getColumn(), r2.getJavaType())); log.debug("Column=" + r2.getColumn() + ", Property=" + r2.getProperty() + ", JavaType=" + r2.getJavaType()); } break; // ?? , ? } } } return DAOprops; }
From source file:org.molasdin.wbase.batis.support.BasicBatisEngine.java
License:Apache License
@Override public String columnByProperty(String property, String resultMap) { ResultMap map = null;//w w w . j a v a 2 s. c om map = session.getConfiguration().getResultMap(resultMap); if (property.contains(".")) { String[] parts = property.split("\\."); property = parts[parts.length - 1]; for (int i = 0; i < parts.length - 1; i++) { resultMap = resultMapNameFromProp(parts[i], map); if (resultMap == null) { throw new IllegalArgumentException( String.format("Can not find result map for property: %s", parts[i])); } map = session.getConfiguration().getResultMap(resultMap); } } else { map = session.getConfiguration().getResultMap(resultMap); } if (property.startsWith("$")) { Integer number = Integer.parseInt(property.replace("$", "")); ResultMapping mapping = map.getConstructorResultMappings().get(number); return mapping.getColumn(); } for (ResultMapping mapping : map.getPropertyResultMappings()) { if (mapping.getProperty().equals(property)) { return mapping.getColumn(); } } throw new IllegalArgumentException(String.format("Can not find property: %s", property)); }
From source file:org.molasdin.wbase.batis.support.BasicBatisEngine.java
License:Apache License
private String resultMapNameFromProp(String prop, ResultMap resultMap) { for (ResultMapping mapping : resultMap.getResultMappings()) { if (mapping.getNestedResultMapId() != null && prop.equals(mapping.getProperty())) { return mapping.getNestedResultMapId(); }//from w w w. ja v a 2 s.c om } return null; }