Copying non-key fields (like clone)
John Abraham <[email protected]> Mon, 02 Mar 2009 20:02:17 -0700
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
I need to be able to duplicate a record, assign it new key values using
the generator, then modify a few of the other (non-key) fields.
I'm updating to version 3.0. In version 2.x I had added a method in
meta called meta.isKeyField(), which allowed me to determine whether a
field was just a normal database field. This allowed me to write a
method like this in one of my classes:
public void copyAllNonRefFields(ParcelORM source) {
for (int i=0;i<fieldValues.length;i++) {
if (!meta.isKeyField(i)) {
fieldValues[i]= source.fieldValues[i];
}
}
setDirty();
}
This worked for me.
What's the best way to do something similar in Version 3? Basically I
want to be able to clone() a record in the database, but obviously the
clone should have a new key generated. I see
SRecordInstance.fieldValues now has package visibility, suggesting that
direct access to it from subclasses (like in my code snippet above) is
no longer a good idea.
Thanks in advance,
(PS coming back to SimpleORM after a bad experience with Hibernate.)
--
John Abraham
[email protected]
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/SimpleORM/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/SimpleORM/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/