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

Constructor Args do not support columnPrefix #968

Closed
christopherpicard opened this Issue Apr 7, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@christopherpicard
Copy link

christopherpicard commented Apr 7, 2017

I use primarily immutable model objects for all of my stored data. As a result all of my member variables are final which means I have to use the constructor args to set them. Currently constructor args do not support the columnPrefix option from associations. As a result I have to build many result maps that are essentially duplicates with different column values since other workarounds are too slow. It would be really nice if the columnPrefix could be added to the constructor arg implementation.

@harawata

This comment has been minimized.

Copy link
Member

harawata commented Apr 7, 2017

Could you provide a test case or example app ?
There is a test case that uses constructor mapping with columnPrefix.
It is possible that there is some corner case to which columnPrefix is not correctly applied, but we need a repro to proceed.

Thank you,
Iwao

@christopherpicard

This comment has been minimized.

Copy link
Author

christopherpicard commented Apr 7, 2017

Sure, I will translate the case I am using into a test case and post it when I am complete.

@Davio

This comment has been minimized.

Copy link

Davio commented Feb 6, 2018

Currently, columnPrefix is only specified for associations. I couldn't find a usage within constructor in the examples.

What I'd like to do is something like the following:

<constructor>
  <idArg name="id" column="id"/>
  <arg name="complexProperty" columnPrefix="prop_" autoMapping="true"/>
 </constructor>

Where complexProperty itself has sub-properties, such as 'key' and 'value' where the columns would be named 'prop_key' and 'prop_value' respectively.

@christopherpicard

This comment has been minimized.

Copy link
Author

christopherpicard commented Feb 13, 2018

As long as resultMaps are supported in that approach it would work for me. My example is like this:

<constructor>
<idArg name="id" column="id"/>
<arg columnPrefix="Minimum" resultMap = "distanceResultMap" javaType="Distance"/>
<arg columnPrefix="Maximum" resultMap = "distanceResultMap" javaType="Distance"/>
...
</constructor>

<resultMap id="distanceResultMap" type="Distance">
<constructor>
<arg column="Distance" javaType="_double"/>
<arg column="DistanceUnits" javaType="String"/>
<constructor>
</resultMap>

The columns in this case would be MinimumDistance, MinimumDistanceUnits, MaximumDistance, and MaximumDistanceUnits.

Currently i have to write two different Result maps for the minimum and maximum value.

@harawata

This comment has been minimized.

Copy link
Member

harawata commented Feb 14, 2018

Thank you for the examples, @Davio @christopherpicard !
I will look into it.

@harawata

This comment has been minimized.

Copy link
Member

harawata commented Jul 29, 2018

Hi @christopherpicard , @Davio

Sorry for a late response, but it will be available in version 3.5.0.
It would be great if you could try the latest SNAPSHOT and see if it works as you expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment