ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Meijer <mjmei...@xs4all.nl>
Subject Updating an EXISTING object with values from DB?
Date Fri, 22 Feb 2008 15:04:54 GMT
I'm working an a generic SQL connector for Mylyn,
bug 184532: [connector] Generic SQL connector
https://bugs.eclipse.org/bugs/show_bug.cgi?id=184532

I need to update an existing java object with new or changed values  
from a DB, sort of like a subscription.

When I use a select statement I get returned a newly created object.  
As follows:
    <select id="getForKey" resultClass="task">
         SELECT
             bug_ID as taskId,
             bug_owner AS owner,
             bug_summary AS summary,
             bug_active as active,
             bug_completed as completed,
             bug_priority_label AS priority,
             bug_notes as notes,
             bug_created AS creationDate,
             bug_scheduled AS scheduledForDate,
             bug_closed AS completionDate,
             bug_due AS dueDate,
             bug_time_estimated / 60 as estimatedTimeHours
         FROM issues INNER JOIN priorities ON issues.bug_priority =  
priorities.bug_priority
         WHERE bug_ID=#value# LIMIT 1
     </select>

The mode="INOUT" only works for procedures. Maybe I'm missing  
something but what I would like is the following:

<refresh id="refreshTask"  parameterClass="task" mode="INOUT">
       SELECT
/*          bug_ID as taskId, cant change */
/*          bug_owner AS owner, cant change */
             bug_summary AS summary,
             bug_active as active,
             bug_completed as completed,
             bug_priority_label AS priority,
             bug_notes as notes,
             bug_created AS creationDate,
             bug_scheduled AS scheduledForDate,
             bug_closed AS completionDate,
             bug_due AS dueDate,
             bug_time_estimated / 60 as estimatedTimeHours
         FROM issues INNER JOIN priorities ON issues.bug_priority =  
priorities.bug_priority
         WHERE bug_ID=#taskID# LIMIT 1
</refresh>

Where the retiurned values from the query will be stored into the  
fields of the object.
Or do I need to do the mapping in java?

Thanks for any pointers or help!

Maarten


Mime
View raw message