Metrics
0
Watch 2.8K Star 5.7K Fork 2.8K

ThinkGem / JeeSite 4.xJavaAGPL-3.0

从表的findList过滤条件失效

Open
tigerA15  Created at

主表类:TgSeries
从表类:ThModel
主从关关系: thModel.fhSeries -> tgSeries.fgSeries, 也就是 @Column(name="fh_series", attrName="fhSeries.fgSeries", label="fh_series", isUpdate=false, isQuery=false)

(注意,默认生成的代码关联的外键是主表的id,这应该是个小bug? 我将其改为fhSeries关联主表的fgSeries)

执行这段代码生成器生成的代码:

/**
	 * 获取单条数据
	 * @param tgSeries
	 * @return
	 */
	@Override
	public TgSeries get(TgSeries tgSeries) {
		TgSeries entity = super.get(tgSeries);
		if (entity != null){
			ThModel thModel = new ThModel(entity);
			thModel.setStatus(ThModel.STATUS_NORMAL);
			entity.setThModelList(thModelDao.findList(thModel));
		}
		return entity;
	}

发现SelectSqlProvider的findList并没能生成带where的sql:
SELECT a.id AS "id", a.fh_series AS "fhSeries.fgSeries", a.fh_model AS "fhModel", .... a.create_date AS "createDate" FROM th_model a ORDER BY a.create_date ASC
生成的sql居然没有where .

total 1 participants

Comments (1)

tigerA15 2019-07-01 09:27

修改成标准的做法, 在从表增加fh_tg_id对应主表的id,
ALTER TABLE th_model ADD COLUMN fh_tg_id character varying(64);
重新生成代码后,主从表编辑检索都没问题,但若将从表的status改为disable, 那上面反映的这个问题还是没解决, 无论你findList前对从表设置了什么过滤条件, 都会失效.
输入图片说明

Sign in and comment

Assignee
Labels
Not set
Project
Milestone
Branch
Scheduled start
Not set
Scheduled end
Not set
Top level
Priority

Help Search

183227_9af5e6a8_1826025 111910_4d91f001_1826025