Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当目标对象的key值与数据源对象的key值类型不一致时,可以指定将目标对象的key值转为对应类型 #153

Closed
urzeye opened this issue Sep 12, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@urzeye
Copy link

urzeye commented Sep 12, 2023

getTheAssociatedSource 方法根据key找数据源时未做自动类型转换,如sourcestarget中的key类型不一致可能导致无法映射
image
image
image

@Createsequence Createsequence added the enhancement New feature or request label Sep 13, 2023
@Createsequence Createsequence added this to the release 2.3.0 milestone Sep 13, 2023
@Createsequence
Copy link
Collaborator

站在 crane4j 的角度,由于数据源五花八门,数据源里面拿到数据用什么类型的 key 来分类的这个是无法确定的,所以这个要自动推断可能不太现实。

不过,可以考虑在下一个版本添加一个在 @AssembleXXX 注解手动指定 key 类型的功能,比如:

@Assemble(container = "foo", keyType = Long.class, props = @Mapping("name"))
private Integer id;

这样的话在 getTheAssociatedSource 方法里面就可以先判断一样,如果从待填充对象取到的 key 类型与指定的类型不一样,就先转换一下。

@Createsequence Createsequence changed the title getTheAssociatedSource 方法根据key找数据源时未做自动类型转换,如sourcestarget中的key类型不一致可能导致无法映射 当目标对象的key值与数据源对象的key值类型不一致时,可以指定将目标对象的key值转为对应类型 Sep 17, 2023
Createsequence added a commit that referenced this issue Sep 17, 2023
…convert the property value corresponding to key to the specified type before filling starts (GitHub #153)
Createsequence added a commit that referenced this issue Sep 17, 2023
…convert the property value corresponding to key to the specified type before filling starts (GitHub #153) (#154)
Createsequence added a commit that referenced this issue Sep 25, 2023
…convert the property value corresponding to key to the specified type before filling starts (GitHub #153) (#154)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants