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

Fixed bugs when dealing with primitives and multiple matching constructors #12

Merged
merged 5 commits into from Feb 20, 2016

Conversation

Projects
None yet
2 participants
@JanMosigItemis
Contributor

JanMosigItemis commented Feb 18, 2016

Hi there,

i noticed the following issues the other day and fixed them:

  • If a result row column contains primitives, the findConstructor algorithm fails to find a matching constructor if the constructors do use box types or vice versa, e. g. the column contains an int but the constructor of the corresponding POJO takes an Integer.
  • If a result row column contains a null reference, an InvocationTargetException having an NPE set as cause might be thrown (depending on the behavior of the POJO's constructor when null arguments are passed). I straightened out the exception handling a bit so that debugging via stack trace gets easier in such situations.

I did also fix a couple of minor issues in the JpaResultMapper unit test cases.

Unfortunately my IDE seems to have a slightly different tab/spaces policy than yours resulting in rather large diffs. If that bothers you, I could try to change the settings and replay my changes.

Regards

JanMosigItemis added some commits Feb 18, 2016

Fixed bug where target types with multiple constructors with argument
count matching the result row column count would confuse the
findConstructor algorithm of JpaResultMapper.
Improved unit tests
- Added NPE related tests for JpaResultMapper
- Fixed some issues related to tests with native queries
@simasch

This comment has been minimized.

Show comment
Hide comment
@simasch

simasch Feb 20, 2016

Owner

Hi Jan,
Thank you very much!

Owner

simasch commented Feb 20, 2016

Hi Jan,
Thank you very much!

@simasch simasch closed this Feb 20, 2016

@simasch simasch reopened this Feb 20, 2016

simasch added a commit that referenced this pull request Feb 20, 2016

Merge pull request #12 from JanMosigItemis/master
Fixed bugs when dealing with primitives and multiple matching constructors

@simasch simasch merged commit 731cdd1 into simasch:master Feb 20, 2016

@simasch

This comment has been minimized.

Show comment
Hide comment
@simasch

simasch Feb 20, 2016

Owner

Hi Jan,

Ich denke wir können uns auch auf Deutsch unterhalten ☺

Vielen Dank für Deinen grossen Beitrag.
Es freut mich sehr, dass Du QLRM weiterbringst.

Ich werde noch heute eine neue Version erstellen.

Viele Grüsse aus der Schweiz
Simon Martinelli

Von: Jan Mosig [mailto:notifications@github.com]
Gesendet: Donnerstag, 18. Februar 2016 15:50
An: simasch/qlrm qlrm@noreply.github.com
Betreff: [qlrm] Fixed bugs when dealing with primitives and multiple matching constructors (#12)

Hi there,

i noticed the following issues the other day and fixed them:

· If a result row column contains primitives, the findConstructor algorithm fails to find a matching constructor if the constructors do use box types or vice versa, e. g. the column contains an int but the constructor of the corresponding POJO takes an Integer.

· If a result row column contains a null reference, an InvocationTargetException having an NPE set as cause might be thrown (depending on the behavior of the POJO's constructor when null arguments are passed). I straightened out the exception handling a bit so that debugging via stack trace gets easier in such situations.

I did also fix a couple of minor issues in the JpaResultMapper unit test cases.

Unfortunately my IDE seems to have a slightly different tab/spaces policy than yours resulting in rather large diffs. If that bothers you, I could try to change the settings and replay my changes.

Regards


You can view, comment on, or merge this pull request online at:

#12

Commit Summary

  • Removed unused imports and member variables -> reduced warning count.
  • Fixed bug where target types with multiple constructors with argument
  • Improved error handling in case a null is passed to a non null tolerant
  • Fixed potential NPE if result row column contains null reference.
  • Improved unit tests

File Changes

  • M src/main/java/org/qlrm/mapper/JpaResultMapper.javahttps://github.com//pull/12/files#diff-0 (198)
  • M src/main/java/org/qlrm/mapper/ResultMapper.javahttps://github.com//pull/12/files#diff-1 (30)
  • M src/test/java/org/qlrm/generator/ClassGeneratorTest.javahttps://github.com//pull/12/files#diff-2 (69)
  • M src/test/java/org/qlrm/mapper/JdbcResultMapperTest.javahttps://github.com//pull/12/files#diff-3 (86)
  • M src/test/java/org/qlrm/mapper/JpaResultMapperTest.javahttps://github.com//pull/12/files#diff-4 (268)
  • M src/test/java/org/qlrm/to/EmployeeTO.javahttps://github.com//pull/12/files#diff-5 (59)

Patch Links:


Reply to this email directly or view it on GitHubhttps://github.com//pull/12.

Owner

simasch commented Feb 20, 2016

Hi Jan,

Ich denke wir können uns auch auf Deutsch unterhalten ☺

Vielen Dank für Deinen grossen Beitrag.
Es freut mich sehr, dass Du QLRM weiterbringst.

Ich werde noch heute eine neue Version erstellen.

Viele Grüsse aus der Schweiz
Simon Martinelli

Von: Jan Mosig [mailto:notifications@github.com]
Gesendet: Donnerstag, 18. Februar 2016 15:50
An: simasch/qlrm qlrm@noreply.github.com
Betreff: [qlrm] Fixed bugs when dealing with primitives and multiple matching constructors (#12)

Hi there,

i noticed the following issues the other day and fixed them:

· If a result row column contains primitives, the findConstructor algorithm fails to find a matching constructor if the constructors do use box types or vice versa, e. g. the column contains an int but the constructor of the corresponding POJO takes an Integer.

· If a result row column contains a null reference, an InvocationTargetException having an NPE set as cause might be thrown (depending on the behavior of the POJO's constructor when null arguments are passed). I straightened out the exception handling a bit so that debugging via stack trace gets easier in such situations.

I did also fix a couple of minor issues in the JpaResultMapper unit test cases.

Unfortunately my IDE seems to have a slightly different tab/spaces policy than yours resulting in rather large diffs. If that bothers you, I could try to change the settings and replay my changes.

Regards


You can view, comment on, or merge this pull request online at:

#12

Commit Summary

  • Removed unused imports and member variables -> reduced warning count.
  • Fixed bug where target types with multiple constructors with argument
  • Improved error handling in case a null is passed to a non null tolerant
  • Fixed potential NPE if result row column contains null reference.
  • Improved unit tests

File Changes

  • M src/main/java/org/qlrm/mapper/JpaResultMapper.javahttps://github.com//pull/12/files#diff-0 (198)
  • M src/main/java/org/qlrm/mapper/ResultMapper.javahttps://github.com//pull/12/files#diff-1 (30)
  • M src/test/java/org/qlrm/generator/ClassGeneratorTest.javahttps://github.com//pull/12/files#diff-2 (69)
  • M src/test/java/org/qlrm/mapper/JdbcResultMapperTest.javahttps://github.com//pull/12/files#diff-3 (86)
  • M src/test/java/org/qlrm/mapper/JpaResultMapperTest.javahttps://github.com//pull/12/files#diff-4 (268)
  • M src/test/java/org/qlrm/to/EmployeeTO.javahttps://github.com//pull/12/files#diff-5 (59)

Patch Links:


Reply to this email directly or view it on GitHubhttps://github.com//pull/12.

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