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

NullPointer in newSqlParameterSource when there is unkonown properties in db #591

Closed
AntonKuzValid opened this issue Dec 5, 2018 · 5 comments
Milestone

Comments

@AntonKuzValid
Copy link

Here is stack -
java.lang.NullPointerException
at org.simpleflatmapper.jdbc.spring.MapPlaceHolderValueGetterSource.(MapPlaceHolderValueGetterSource.java:14)
at org.simpleflatmapper.jdbc.spring.SqlParameterSourceBuilder.buildSource(SqlParameterSourceBuilder.java:121)
at org.simpleflatmapper.jdbc.spring.DynamicPlaceHolderValueGetterSource.addColumn(DynamicPlaceHolderValueGetterSource.java:49)
at org.simpleflatmapper.jdbc.spring.DynamicPlaceHolderValueGetterSource.getPlaceHolderValueGetter(DynamicPlaceHolderValueGetterSource.java:30)
at org.simpleflatmapper.jdbc.spring.SqlParameterSourceImpl.hasValue(SqlParameterSourceImpl.java:16)
at org.springframework.jdbc.core.metadata.TableMetaDataContext.matchInParameterValuesWithInsertColumns(TableMetaDataContext.java:214)
at org.springframework.jdbc.core.simple.AbstractJdbcInsert.matchInParameterValuesWithInsertColumns(AbstractJdbcInsert.java:611)
at org.springframework.jdbc.core.simple.AbstractJdbcInsert.doExecute(AbstractJdbcInsert.java:346)
at org.springframework.jdbc.core.simple.SimpleJdbcInsert.execute(SimpleJdbcInsert.java:121)
at ru.evotor.monitor.repository.impl.MacAddressRepositoryImpl.insert(MacAddressRepositoryImpl.kt:45)
at ru.evotor.monitor.repository.impl.MacAddressRepositoryImpl$$FastClassBySpringCGLIB$$978c6a17.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at ru.evotor.monitor.repository.impl.MacAddressRepositoryImpl$$EnhancerBySpringCGLIB$$9b8d7715.insert()
at ru.evotor.monitor.repository.impl.MacAddressRepositoryImplTest.insert(MacAddressRepositoryImplTest.kt:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

The problem appeared when i add new column to table whcih is not described in the model

here is my config -
@bean
fun macAddressSource() = JdbcTemplateMapperFactory.newInstance()
.ignorePropertyNotFound()
.addAlias("timestamp_", "timestamp")
.addColumnProperty("timestamp_", SqlTypeColumnProperty.of(Types.TIMESTAMP))
.newSqlParameterSourceFactory(MacAddressRecord::class.java)!!

So it worked nice before a added an unknown column

@arnaudroger
Copy link
Owner

Thanks will have a look.

@arnaudroger
Copy link
Owner

is the unknown property in the MacAddressRecord class? what type? is there a getter?

@arnaudroger
Copy link
Owner

oh missed the ignorePropertyNotFound ....

@arnaudroger
Copy link
Owner

so the expected behaviour is hasValue to return false for that, instead of NPE. will be fix in next release should be in maven central later tonight.

@arnaudroger arnaudroger added this to the 6.0.10 milestone Dec 5, 2018
@arnaudroger
Copy link
Owner

just pushed 6.0.10 to maven central should be available in 10 - 30 mn.
that should fix that issue.
For curiosity, I'm actually not that familiar with SqlParameterSource. in this case, the param value will need to be provided by another source? are you combining 2 SqlParameterSource together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants