예제 #1
0
void Mapping::addDataSourceEntityMapping(const DataSourceEntityMapping& dsemp) {
	if(dsemp.getClassName()!="" && dseMap.find(dsemp.getClassName())==dseMap.end()) {
		dseMap[dsemp.getClassName()] = dsemp;
		if(!dsemp.isEmbedded()) {
			tableClassMapping[dsemp.getTableName()] = dsemp.getClassName();
		}
	}
}
예제 #2
0
void DataSourceInterface::assignId(DataSourceEntityMapping& dsemp, ClassInfo& clas, void* entity) {
	GenericObject idv;
	next(dsemp, idv);
	if(!idv.isNull())
	{
		Field fld = clas.getField(dsemp.getIdPropertyName());
		vector<void *> valus;
		if(GenericObject::isNumber32(idv.getTypeName()) && GenericObject::isNumber(fld.getType()))
		{
			long* id;
			idv.get(id);
			valus.push_back(id);
		}
		else if(GenericObject::isNumber64(idv.getTypeName()) && GenericObject::isNumber(fld.getType()))
		{
			long long* id;
			idv.get(id);
			valus.push_back(id);
		}
		else if(GenericObject::isFPN(idv.getTypeName()) && GenericObject::isFPN(fld.getType()))
		{
			long double* id;
			idv.get(id);
			valus.push_back(id);
		}
		else if(GenericObject::isString(idv.getTypeName()) && GenericObject::isString(fld.getType()))
		{
			string* id;
			idv.set(id);
			valus.push_back(id);
		}
		else
		{
			throw "Data-Source-Object/Entity types do not match for id property" + dsemp.getClassName() + ":" + dsemp.getIdPropertyName();
		}

		args argus;
		argus.push_back(fld.getType());
		string methname = "set"+StringUtil::capitalizedCopy(fld.getFieldName());
		Method meth = clas.getMethod(methname,argus);
		reflector->invokeMethodGVP(entity,meth,valus);
	}
}