Hi, all,

I hope I'm missing something obvious, but I just can't peg it. I was
purposely changing the key property of a Transfer object in a unit
test object so I could test my validate() method (in my TO decorator).
Suddenly a bunch of assertions that were successful started failing. I
realized that I'm getting the cached version with the altered key
field.

For simplicity, assume I have a usstate table with a PK column named
abbreviation-char(2) and column named statename-varchar(20). I have
the 'abbreviation' column aliased as 'stateCode' as you can see in
this transfer.xml snippet:

<package name="location">
        <object name="UsState" table="usstate"
decorator="model.location.UsState">
                <id name="stateCode" type="string" column="abbreviation" />
                <property name="stateName" type="string" column="statename" />
        </object>
</package>

When I get a state object with key 'NY' and change that key to
'' (empty string), I can't seem to then discard this cached dirty
object and access a fresh one from the database (unless I use the
discardAll() method). I've tried discard() and I've tried
discardByClassAndKey() with both the persisted key ('NY') and the
dirty/changed one (''). Another get() for that object continues to
return the dirty one, until I call discardAll() or restart the CF
service.

Here's my test code, with comments stating the output I'm seeing...

transfer.discardAll();

stateNY = transfer.get('location.UsState', 'NY');
writeOutput(stateNY.getStateCode() & '<br />'); //output is "NY"
writeOutput(stateNY.getIsDirty() & '<br />'); //output is "false"

stateNY.setStateCode('');
writeOutput(stateNY.getStateCode() & '<br />'); //output is ""
writeOutput(stateNY.getIsDirty() & '<br />'); //output is "true"

transfer.discard(stateNY);
writeOutput(stateNY.getStateCode() & '<br />'); //output is ""
writeOutput(stateNY.getIsDirty() & '<br />'); //output is "true"

transfer.discardByClassAndKey('location.UsState', 'NY');
writeOutput(stateNY.getStateCode() & '<br />'); //output is ""
writeOutput(stateNY.getIsDirty() & '<br />'); //output is "true"

transfer.discardByClassAndKey('location.UsState', '');
writeOutput(stateNY.getStateCode() & '<br />'); //output is ""
writeOutput(stateNY.getIsDirty() & '<br />'); //output is "true"

Any thoughts would be much appreciated!

Thanks!
Jamie
--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to