Cute Happy Ghost
본문 바로가기
JAVA/Java error

There is no getter for property named 'id' in 'class java.lang.String'

by JENN_tech7 2021. 11. 3.
728x90
SMALL

 

map.put("info",saveJson.get("info"));
map.put("resn",saveJson.get("resn"));
map.put("user",getUserInfo(request));

컨트롤러는 대략 이랬고

 

 

 

맵은 대략 이런식으로 구성되어있음

{ resn=[{fclt_nm=㈜재톨, , rcy_cd=폐섬유류, oldValue=0, value=343, mdfy_resn=ggg, sts_wst_type_cd=RCY0104}]
, user={ratio_cd=1, work=관리자, is_valid_pw=SUCCESS, isLogined=true, dpt=관리자, reg_date=2021-10-05 00:00:00.0, sgg=23040, users_role=4, upd_date=2021-10-05 16:35:01.0, name=테스트, users_sn=2, tel=, id=test1, email=}
, info=[{fclt_year=2021, fclt_mth=11, fclt_nm=㈜재톨, fclt_sn=1325}]}

 

 

 

mybatis 쿼리문 insert는 대략 이러했다

INSERT INTO t_hist_life_mrs(
			old_val
			,new_val
			,mdfy_resn
			,sts_wst_type_cd
			,fclt_sn
			,user_id
			
        ) VALUES 
        	<foreach collection="resn" item="resn"   separator=",">
			 	( 
			 	 #{resn.oldValue}
			 	, #{resn.value}
			 	, #{resn.mdfy_resn}
			 	, #{resn.sts_wst_type_cd}
	        	<foreach collection="info" item="info"  separator=",">
				 	, #{info.fclt_sn}::int 
				</foreach>
                <foreach collection="user" item="user"  separator=",">
				 	, #{user.id}
				</foreach>
				 	)
			</foreach>

map안에 resn과 info와 user를 각각 foreach에 넣어서 돌려주는 것이었다(다른 데이터들도 있어서 foreach돌려야하는상황) 

하지만 저런 에러를 맞닥뜨리고 만것

 

 

 

There is no getter for property named 'id' in 'class java.lang.String'

정확한 이유는 모르지만 collection이 아니라서? (모름) getter setter를 매핑할 수 없어서 그렇다고 한다

그래서 collection을 빼주고 그냥 user안에 있는 id를 가져오니까 해결완

INSERT INTO t_hist_life_mrs(
			old_val
			,new_val
			,mdfy_resn
			,sts_wst_type_cd
			,fclt_sn
			,user_id
			
        ) VALUES 
        	<foreach collection="resn" item="resn"   separator=",">
			 	( 
			 	 #{resn.oldValue}
			 	, #{resn.value}
			 	, #{resn.mdfy_resn}
			 	, #{resn.sts_wst_type_cd}
	        	<foreach collection="info" item="info"  separator=",">
				 	, #{info.fclt_sn}::int 
				</foreach>
				 	, #{user.id}
				 	)
			</foreach>
728x90
LIST

댓글