The configuration type mapping should also search for implemented interfaces

Bug #650753 reported by Luis Fernando Planella Gonzalez on 2010-09-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Unassigned

Bug Description

Previously, there was a request for configuration to search for a type registered for superclasses, so, for example, having a Type for Calendar would also work with GregorianCalendar.
However, now I've faced a new one: This should also be extended to interfaces.
The concrete example was the BlobType (registered by default), which returns java.sql.Blob as java type.
However, each JDBC driver has it's own Blob implementation (for example, com.mysql.jdbc.Blob), and the configuration cannot find a class for it.

I've attached a patch for this. Feel free to reject / change at will. I've done the following:

* As it could involve looking up on superclasses and all implemented interfaces (both by the class itself and any of it's superclasses), it could be a long lookup. Also, as those lookups could happen several times per query, I've created another map that maps a class to the effectively resolved type, so, future invocations would just lookup on that map.

* Added a method to resolve all implemented interfaces of a class and it's subclasses. This is not the best place for such a method (maybe on some utility class). There is an implementation of this in commons lang, on the ClassUtils.getAllInterfaces).

* Changed the type finding itself to a separate method, findType, and made getType handle the lookup on the resolvedTypesByClass map, and invoke the findType when needed.

Tags: sql Edit Tag help
tags: added: sql

Thanks for the bug report and patch. Fixed in SVN trunk.

Changed in querydsl:
status: New → Fix Committed
Changed in querydsl:
importance: Undecided → Medium

Released in 2.0.1

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers