Re: Migration and use of ERXJDBCUtilities.executeUpdate
Re: Migration and use of ERXJDBCUtilities.executeUpdate
- Subject: Re: Migration and use of ERXJDBCUtilities.executeUpdate
- From: Mike Schrag <email@hidden>
- Date: Mon, 12 May 2008 09:52:21 -0400
which indicates that the primary key has already been used.
Is it a "bad" practice to use the standard EO way to create my
datasets in migration e.g.
User user = new User();
ec.insertObject(user);
user.set...
...
ec.saveChanges();
This would set the correct PK's and then everything works fine.
Yes, very bad ... When that migration runs, it is very possible that
it does not match the current version of your EOModel. For instance,
imagine that you add an extra not-null attribute to your User entity.
So you are inserting in migration 1 out of 5, and the new attribute
was added in version 5. EOModels are unversioned and thus ALWAYS
match the latest migration version, so the model is going to attempt
to insert a User with this additional attribute which doesn't exist
yet in the version of the table that your migration is running on.
Generally this is an issue of initial data insertion (i.e. the
"Migration Zero" data). You need to wait till all migrations run, so
your databases match your models and THEN run these inserts against
EOF. The way to do this is by implementing IERXPostMigration on your
migration. When all migrations finish running, it then takes the list
of post migrations and executes them. There are some caveats about
post migrations and transactions that I believe is documented in the
package.html for migrations that you should be aware of.
ms
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden