Handling of Hibernate Report Queries leads to ClassCastExceptions -----------------------------------------------------------------
Key: SPRING-84 URL: http://jira.andromda.org/browse/SPRING-84 Project: Spring Cartridge Type: Bug Versions: 3.1M1 Environment: AndroMDA setup including Spring and Hibernate cartridge, modelling done by Together and own XMI-exporter, Windows XP, generation via ANT-task Reporter: Dirk Rademann Assigned to: Chad Brandon By using Hibernate report queries like select entity.property1, entity.property2 from SomeEntityImpl entity where entity.id = ? the Spring Cartridge generates code (...DaoBase) that tries to cast the result of the query into the given entity class, in the example given above that would be like ... java.util.List results = queryObject.list(); result = (SomeEntityImpl)results.iterator().next(); resulting in a ClassCastException cause the query returns an Object[] with two values (property1 and property2), not an entity. The entity itself is connected to a tagged <<ValueObject>> and the transform methods are also generated and implemented: to<name of value object>(SomeEntityImpl entity) and(!) to<name of value object>(Object[] entity) That means that the transform methods are generated correctly already and if I use a finder with the specific constant for a value object transformation the code should call the to<name of value object>(Object[] entity) method prior to doing anything else like it is already doing for Collections of entites which are transformed into value objects. Currently you can't use Hibernate report queries that return one single row. Only workaround at the moment is to use a Collection as return value. regards, Dirk Rademann -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.andromda.org/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Andromda-devel mailing list Andromda-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/andromda-devel