Re: Copying non-key fields (like clone)
[email protected] Wed, 04 Mar 2009 17:34:26 +1000
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
Welcome back.
Is SFieldScalar.isPrimaryKey what you want?
(SimpleORM 3.0 is more focused on columns than references, which simplifies it.)
In general, all variables should have package scope. Then you can write your own class and put it in the simpleorm package and poke at them. But only in emergencies!
If you end up producing a number of useful methods like clone, then put them in a package like SRecordUtil and we will incorporate them into the source. But be sure to include a test case.
Regards,
Anthony
At 01:02 PM 3/03/2009, you wrote:
>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
><mailto:jabraham%40ucalgary.ca>[email protected]
>
Spreadsheet Detective,
Southern Cross Software Queensland Pty Limited
54 Gerler Street
Bardon, Queensland 4065, Australia.
Email: [email protected]
www.SpreadsheetDetective.com
Ph: +61 427 830248 (Australian Eastern Standard Time)
"If the model seems correct only because the numbers look right,
then why build the model in the first place?"
------------------------------------
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/
b82110c.jpg
(image/jpeg, 3.3 KB) - not displayed