Re: WO and MySQL
Re: WO and MySQL
- Subject: Re: WO and MySQL
- From: Arturo Perez <email@hidden>
- Date: Mon, 17 Oct 2005 11:54:03 -0400
LD wrote:
[1] The postgres serial type automatically creates a sequenced
called: <tableName>_<pkColumn>_SEQ whereas the current version of
the plugin looks for a sequence called <tableName>_SEQ.
You might having trouble that the user that is connecting to the
database does not have permission to generate new tables. The wonder
plugin used to generate a EO_PK_TABLE.
You can view the source online here:
http://cvs.sourceforge.net/viewcvs.py/wonder/Wonder/PlugIns/
PostgresqlPlugIn/Sources/com/webobjects/jdbcadaptor/
PostgresqlPlugIn.java has
protected static String sequenceNameForEntity(EOEntity entity) {
return entity.primaryKeyRootName() + "_SEQ";
}
i.e., <tableName>_SEQ
Customise it as required. I suggest something like the following if you
want it to be automatically compatible with using the "serial" column
type sequences as created by postgres.
protected static String sequenceNameForEntity( EOEntity entiy ) {
StringBuffer sequenceName;
sequenceName = new StringBuffer();
sequenceName.append( entity.primaryKeyRootName() ); // i.e., the
table name
sequenceName.append( entity.primaryKeyAttributeNames ().valueForKey(
"columnName" ).componentsJoinedByString( "_" ) );
sequenceName.append( "_SEQ" );
return sequenceName.toString();
}
i.e., <tableName>_<primaryKey0>_<primaryKeyN>_SEQ. In most cases where
there's a single primary key: <tableName>_<primaryKey0>_SEQ
That's pretty nice. I would suggest modifying it to detect if the
column type is SERIAL and then you'll have the best of both worlds.
_______________________________________________
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