Search the web
Sign In
New User? Sign Up
SimpleORM
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Works with Access?   Message List  
Reply | Forward Message #1538 of 1851 |
Re: [SimpleORM] Copying values directly

Looks good to me. Best to avoid detaching. Note how easy it was to
write the copying code. Sorry for not responding earlier, I missed it.

Anthony

At 02:09 AM 24-11-07, John Abraham wrote:

>I have a need to copy a record in a database, and then modify the
>original and the copy. I make a new record using
>
>ParcelORM newOne = (ParcelORM) ParcelORM.meta.createWithGeneratedKey();
>then I want to copy all of the fields except the key field (which has
>been generated).
>
>I can't use clone() because it won't work once I'm attached. So I'm
>proceeding as shown below, and would appreciate any feedback.
>
>First I wrote code in my user object to copy the fields:
>
>for (int i=0;i<fieldValues.length;i++) {
>if (!meta.isKeyField(i)) {
>fieldValues[i]= source.fieldValues[i];
>}
>}
>setDirty();
>
>The I added this method to SRecordMeta:
>
>public boolean isKeyField(int i) {
>for (int k=0;k<keySFieldMetas.size();k++) {
>SFieldMeta s = (SFieldMeta) keySFieldMetas.get(k);
>if (s.fieldIndex==i) return true;
>}
>return false;
>}
>
>}
>
>So I'm copying all the fields that aren't key fields. The foreign key
>fields might still be a problem, I don't have any foreign keys so it's
>hard to know.
>
>Another approach would be to detach the original, use the deprecated
>clone() method, then try to reattach the original and attach the copy.
>But that seems overly complex.
>
>--
>John Abraham
><mailto:jabraham%40ucalgary.ca>jabraham@...
>

EMail: berglas@...

+61 7 3369 4065 (Australian Eastern Standard Time)

If the model seems correct only because the numbers look right,
then why build the model in the first place?




Sun Dec 16, 2007 4:18 am

berglas@...
Send Email Send Email

Forward
Message #1538 of 1851 |
Expand Messages Author Sort by Date

Hi, I'm just starting to use SimpleORM and I think it will work for me. One thing, though, is that although much of my work is with MySQL, SQL Server, or...
jeabraham
Offline Send Email
Nov 20, 2007
12:20 am

SimpleORM uses pretty standard SQL, and the drivers that customize it for databases are fairly straight forward to adapt. But have not tried Access. Anthony ...
Anthony & Melissa Ber...
berglas@...
Send Email
Nov 21, 2007
1:33 am

I have a need to copy a record in a database, and then modify the original and the copy. I make a new record using ParcelORM newOne = (ParcelORM)...
John Abraham
jeabraham
Offline Send Email
Nov 23, 2007
4:09 pm

Looks good to me. Best to avoid detaching. Note how easy it was to write the copying code. Sorry for not responding earlier, I missed it. Anthony ... EMail:...
Anthony & Melissa Ber...
berglas@...
Send Email
Dec 16, 2007
4:18 am

SimpleORM seems to work fine with Microsoft Access via JDBC:ODBC if you manually set the driver to SQLServer. Should this be added to the documentation? ...
John Abraham
jeabraham
Offline Send Email
Nov 23, 2007
4:13 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help