NutzCN Logo
问答 使用@one的一个小问题
发布于 129天前 作者 qq_f107e7ef 178 次浏览 复制 上一个帖子 下一个帖子
标签:

在nutz dao中,添加两个@one,并且这两个属性都是同一个类型,会报错,可能是因为sql别名相同报错吧,@one可以自己设置sql别名吗?

	@Column("main_leader_sid")
	private String mainLeaderSid;
	/**
	 * 
	 */
	@Column("sub_leader_sid")
	private String subLeaderSid;

	/**
	 *  field为java字段名   使用one时,字段要加上 Column
	 */
	@One(field="mainLeaderSid")
	@Column
	private SysUser mainLeader;
	
	@One(field="subLeaderSid")
	@Column
	private SysUser subLeader;

org.nutz.dao.DaoException: !Nutz SQL Error: 'SELECT ec_new_activity.sid as sid,ec_new_activity.new_act_code as new_act_code,ec_new_activity.new_act_name as new_act_name,ec_new_activity.arrange_time as arrange_time,ec_new_activity.new_act_start_time as new_act_start_time,ec_new_activity.new_act_end_time as new_act_end_time,ec_new_activity.act_type as act_type,ec_new_activity.flag_status as flag_status,ec_new_activity.date_create as date_create,ec_new_activity.date_modify as date_modify,ec_new_activity.user_create as user_create,ec_new_activity.user_modify as user_modify,ec_new_activity.act_province as act_province,ec_new_activity.act_city as act_city,ec_new_activity.act_county as act_county,ec_new_activity.act_town as act_town,ec_new_activity.act_desc as act_desc,ec_new_activity.remark as remark,ec_new_activity.main_leader_sid as main_leader_sid,ec_new_activity.sub_leader_sid as sub_leader_sid , sys_user.sid as sys_user_z_sid,sys_user.organization_id as sys_user_z_organization_id,sys_user.openid as sys_user_z_openid,sys_user.user_name as sys_user_z_user_name,sys_user.user_pwd as sys_user_z_user_pwd,sys_user.nickname as sys_user_z_nickname,sys_user.user_real_name as sys_user_z_user_real_name,sys_user.user_phone as sys_user_z_user_phone,sys_user.user_email as sys_user_z_user_email,sys_user.user_type as sys_user_z_user_type,sys_user.role_id as sys_user_z_role_id,sys_user.job_number as sys_user_z_job_number,sys_user.icon as sys_user_z_icon,sys_user.flag_status as sys_user_z_flag_status,sys_user.date_create as sys_user_z_date_create,sys_user.date_modify as sys_user_z_date_modify,sys_user.user_create as sys_user_z_user_create,sys_user.user_modify as sys_user_z_user_modify,sys_user.remark as sys_user_z_remark , sys_user.sid as sys_user_z_sid,sys_user.organization_id as sys_user_z_organization_id,sys_user.openid as sys_user_z_openid,sys_user.user_name as sys_user_z_user_name,sys_user.user_pwd as sys_user_z_user_pwd,sys_user.nickname as sys_user_z_nickname,sys_user.user_real_name as sys_user_z_user_real_name,sys_user.user_phone as sys_user_z_user_phone,sys_user.user_email as sys_user_z_user_email,sys_user.user_type as sys_user_z_user_type,sys_user.role_id as sys_user_z_role_id,sys_user.job_number as sys_user_z_job_number,sys_user.icon as sys_user_z_icon,sys_user.flag_status as sys_user_z_flag_status,sys_user.date_create as sys_user_z_date_create,sys_user.date_modify as sys_user_z_date_modify,sys_user.user_create as sys_user_z_user_create,sys_user.user_modify as sys_user_z_user_modify,sys_user.remark as sys_user_z_remark FROM ec_new_activity LEFT JOIN sys_user ON ec_new_activity.main_leader_sid = sys_user.sid LEFT JOIN sys_user ON ec_new_activity.sub_leader_sid = sys_user.sid WHERE ec_new_activity.sid='{
"status" : "1"
}' LIMIT 0, 1 '
PreparedStatement:
'SELECT ec_new_activity.sid as sid,ec_new_activity.new_act_code as new_act_code,ec_new_activity.new_act_name as new_act_name,ec_new_activity.arrange_time as arrange_time,ec_new_activity.new_act_start_time as new_act_start_time,ec_new_activity.new_act_end_time as new_act_end_time,ec_new_activity.act_type as act_type,ec_new_activity.flag_status as flag_status,ec_new_activity.date_create as date_create,ec_new_activity.date_modify as date_modify,ec_new_activity.user_create as user_create,ec_new_activity.user_modify as user_modify,ec_new_activity.act_province as act_province,ec_new_activity.act_city as act_city,ec_new_activity.act_county as act_county,ec_new_activity.act_town as act_town,ec_new_activity.act_desc as act_desc,ec_new_activity.remark as remark,ec_new_activity.main_leader_sid as main_leader_sid,ec_new_activity.sub_leader_sid as sub_leader_sid , sys_user.sid as sys_user_z_sid,sys_user.organization_id as sys_user_z_organization_id,sys_user.openid as sys_user_z_openid,sys_user.user_name as sys_user_z_user_name,sys_user.user_pwd as sys_user_z_user_pwd,sys_user.nickname as sys_user_z_nickname,sys_user.user_real_name as sys_user_z_user_real_name,sys_user.user_phone as sys_user_z_user_phone,sys_user.user_email as sys_user_z_user_email,sys_user.user_type as sys_user_z_user_type,sys_user.role_id as sys_user_z_role_id,sys_user.job_number as sys_user_z_job_number,sys_user.icon as sys_user_z_icon,sys_user.flag_status as sys_user_z_flag_status,sys_user.date_create as sys_user_z_date_create,sys_user.date_modify as sys_user_z_date_modify,sys_user.user_create as sys_user_z_user_create,sys_user.user_modify as sys_user_z_user_modify,sys_user.remark as sys_user_z_remark , sys_user.sid as sys_user_z_sid,sys_user.organization_id as sys_user_z_organization_id,sys_user.openid as sys_user_z_openid,sys_user.user_name as sys_user_z_user_name,sys_user.user_pwd as sys_user_z_user_pwd,sys_user.nickname as sys_user_z_nickname,sys_user.user_real_name as sys_user_z_user_real_name,sys_user.user_phone as sys_user_z_user_phone,sys_user.user_email as sys_user_z_user_email,sys_user.user_type as sys_user_z_user_type,sys_user.role_id as sys_user_z_role_id,sys_user.job_number as sys_user_z_job_number,sys_user.icon as sys_user_z_icon,sys_user.flag_status as sys_user_z_flag_status,sys_user.date_create as sys_user_z_date_create,sys_user.date_modify as sys_user_z_date_modify,sys_user.user_create as sys_user_z_user_create,sys_user.user_modify as sys_user_z_user_modify,sys_user.remark as sys_user_z_remark FROM ec_new_activity LEFT JOIN sys_user ON ec_new_activity.main_leader_sid = sys_user.sid LEFT JOIN sys_user ON ec_new_activity.sub_leader_sid = sys_user.sid WHERE ec_new_activity.sid=? LIMIT 0, 1 '
CaseMessage=Not unique table/alias: 'sys_user'

3 回复

EcNewActivity activity = getQueryDB().fetchByJoin(EcNewActivity.class, null, sid);

@One不能跟@Column一起写

哦,知道了,文章看错了
但好像写了运行也是正常的咧
但那个别名相同,有没有别的办法啊,只能使用老方法 fetchLinks 吗?

添加回复
请先登陆
回到顶部