Hi there,

On 18/10/2005, at 1:54 AM, Arturo Perez wrote:

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.

Well, the above is a snippet really of what I was working on a month or so ago (but haven't had time to complete. i.e., test) where I do indeed test for various sequence names the first time around; upon discovery we save it in the user info for the entity to save round- trips the next time.

I'll have to get back onto that...

with regards,
--

LD


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to