[ http://jira.andromda.org/browse/SPRING-84?page=all ]

David Allen updated SPRING-84:
------------------------------

    Attachment: dao-patch.txt

> 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
>     Assignee: Chad Brandon
>  Attachments: dao-patch.txt
>
> 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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Reply via email to