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

SelectQueryMapper should support LocalDate #710

Closed
khauser opened this issue Mar 18, 2020 · 8 comments
Closed

SelectQueryMapper should support LocalDate #710

khauser opened this issue Mar 18, 2020 · 8 comments
Milestone

Comments

@khauser
Copy link
Contributor

khauser commented Mar 18, 2020

Having a simple SQL:

		SelectSeekStep1<Record4<Long, LocalDate, String, BigDecimal>, LocalDate> sql1 = dsl
				.select(booking.ID, booking.BOOKING_DATE, booking.NAME, booking.VALUE)//
				.from(booking)//
				.orderBy(booking.BOOKING_DATE.desc());
		JdbcMapper<Booking> testMapper = JdbcMapperFactory.newInstance()
				.newMapper(Booking.class);		

does deliver results with filled booking_date field, whereas

		SelectQueryMapper<Booking> mapper = SelectQueryMapperFactory.newInstance().newMapper(Booking.class);

delivers an empty field.

@arnaudroger
Copy link
Owner

will have a look thanks for the report

@arnaudroger arnaudroger added this to the 8.2.2 milestone Apr 15, 2020
@arnaudroger
Copy link
Owner

that should be fixed in 8.2.2

@khauser
Copy link
Contributor Author

khauser commented Apr 16, 2020

I have upgraded now, but stuck in a case #658 we had in 2019 ;) with this inheritance strategy.

The following lines do not compile anymore:

JdbcMapper<TopicOverviewItem> mapper2 = JdbcMapperFactory.newInstance()
                        .discriminator(BaseTestPlan.class, builder -> builder.when(rs -> true, DwhTestPlan.class))
                        .newMapper(TopicOverviewItem.class);

I already replaced rs -> true with rs -> ConstantPredicate.truePredicate() while eclipse then shows me:

The method when(Function<List<JdbcColumnKey>,Predicate<ResultSet>>, Class<? extends BaseTestPlan>) is ambiguous for the type AbstractMapperFactory.DiscriminatorBuilder<ResultSet,JdbcColumnKey,BaseTestPlan>

Next try was with the compiling lines:

JdbcMapper<TopicOverviewItem> mapper2 = JdbcMapperFactory.newInstance()
                        .discriminator(BaseTestPlan.class).with(DwhTestPlan.class)
                        .newMapper(TopicOverviewItem.class);

which ends in a:

java.lang.ClassCastException: org.simpleflatmapper.reflect.ClassMetaWithDiscriminatorId cannot be cast to org.simpleflatmapper.reflect.meta.ClassMeta
	at org.simpleflatmapper.map.impl.DiscriminatorReflectionService.newClassMeta(DiscriminatorReflectionService.java:85)
	at org.simpleflatmapper.map.impl.DiscriminatorReflectionService.getClassMeta(DiscriminatorReflectionService.java:69)
	at org.simpleflatmapper.reflect.meta.PropertyMeta.newPropertyClassMeta(PropertyMeta.java:53)
	at org.simpleflatmapper.reflect.meta.PropertyMeta.getPropertyClassMeta(PropertyMeta.java:46)
	at org.simpleflatmapper.reflect.meta.ObjectPropertyFinder.lookForSubProperty(ObjectPropertyFinder.java:288)
	at org.simpleflatmapper.reflect.meta.ObjectPropertyFinder.lookForProperty(ObjectPropertyFinder.java:218)
	at org.simpleflatmapper.reflect.meta.ObjectPropertyFinder.lookForProperties(ObjectPropertyFinder.java:72)
	at org.simpleflatmapper.reflect.meta.PropertyFinder.lookForProperties(PropertyFinder.java:55)
	at org.simpleflatmapper.reflect.meta.PropertyFinder.findProperty(PropertyFinder.java:38)
	at org.simpleflatmapper.reflect.meta.PropertyFinder.findProperty(PropertyFinder.java:33)
	at org.simpleflatmapper.map.mapper.PropertyMappingsBuilder._addProperty(PropertyMappingsBuilder.java:97)
	at org.simpleflatmapper.map.mapper.PropertyMappingsBuilder.addProperty(PropertyMappingsBuilder.java:70)
	at org.simpleflatmapper.map.mapper.DefaultConstantSourceMapperBuilder.addMapping(DefaultConstantSourceMapperBuilder.java:147)
	at org.simpleflatmapper.map.mapper.SetRowMapperBuilderImpl.addMapping(SetRowMapperBuilderImpl.java:213)
	at org.simpleflatmapper.map.mapper.MapperBuilder.addMapping(MapperBuilder.java:142)
	at org.simpleflatmapper.map.mapper.MapperBuilder.addMapping(MapperBuilder.java:152)
	at org.simpleflatmapper.jdbc.JdbcMapperFactory$SetRowMapperFactory.newInstance(JdbcMapperFactory.java:351)
	at org.simpleflatmapper.jdbc.JdbcMapperFactory$SetRowMapperFactory.newInstance(JdbcMapperFactory.java:339)
	at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.getMapper(DynamicSetRowMapper.java:104)
	at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.getMapperFromSet(DynamicSetRowMapper.java:94)
	at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.stream(DynamicSetRowMapper.java:70)
	at org.simpleflatmapper.jdbc.JdbcMapperFactory$DynamicJdbcSetRowMapper.stream(JdbcMapperFactory.java:292)

@arnaudroger
Copy link
Owner

I'll check that out.
looks like some generic erasure makes the call ambiguous usually can get around that by casting explictky the lamba to the targeted type.

@khauser
Copy link
Contributor Author

khauser commented Apr 23, 2020

I added #717 with what it should work with

@arnaudroger arnaudroger modified the milestones: 8.2.2, 8.3.0 May 10, 2020
@arnaudroger
Copy link
Owner

Thanks I have a bit more time at the minute, so will have try that out

@arnaudroger arnaudroger reopened this May 10, 2020
@arnaudroger arnaudroger modified the milestones: 8.3.0, 8.2.3 May 10, 2020
@arnaudroger
Copy link
Owner

just pushed 8.2.3 to maven central - it should be available in the next 30 min.
the test from the PR is passing with that

@khauser
Copy link
Contributor Author

khauser commented May 29, 2020

Thanks @arnaudroger

@khauser khauser closed this as completed May 29, 2020
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