Re: solved: EOCustomObject.storedValueForKey?!?

2015-01-12 Thread OC
Chuck,

On 12. 1. 2015, at 7:50, Chuck Hill ch...@gevityinc.com wrote:
 It should find it.  Where / how did you add it?

A pretty typical d'oh moment. Sort of I supposed the „creates an EOAttribute 
whose parent is owner“ part of

attr=new EOAttribute(ad,entity)

would, ahem, actually _add_ the attribute to the owner. It does not. 
Contrariwise,

attr=new EOAttribute(ad,entity)
entity.addAttribute(attr)

works all right, it seems.

 How are you telling that it was not added?

Logged out at first eo.attributes, then the entity of my eo, and eventually 
both the 'attr' and 'entity' pre- and post- creation in the code above, like

attr=new EOAttribute(ad,entity)
println WTH?!?\nattr: $attr\nent: $entity

Thanks a lot,
OC

 On 2015-01-11, 10:37 PM, OC wrote:
 
 Probably found the culprit.
 
 I have added the appropriate attribute programmatically to the entity; and it 
 seems that it was NOT added -- and therefore storedValueForKey did not find 
 it. Makes sense. Oh, sigh.
 
 All the best,
 OC
 
 
 On 12. 1. 2015, at 6:59, OC o...@ocs.cz wrote:
 
 Hello there,
 I must be missing something very obvious now.
 My application (rather complex) lately started sometimes to go stack 
 overflow. I have found the culprit is a code where I call storedValueForKey 
 in my own ERXGenericRecord subclass. The stack goes like this:
 (i) handleQueryWithUnboundKey (which my EO overrides) get called -- I do some 
 internal checking there, and eventually call my own installed accessor, 
 essentially, 'this.foo()'. That works well.
 (ii) the 'foo' accessor contains just this.storedValueForKey('foo'), and it 
 indeed gets called all right.
 (iii) now, I thought it would try to get the value of 'foo' from snapshot, or 
 fetch it from the database, or whatever. I was wrong -- it goes again to 
 handleQueryWithUnboundKey, GOTO (i), stack overflow.
 Here's the important part of backtrack:
 ===
 ...
 at 
 cz.ocs.model.OCSEnterpriseObject.handleQueryWithUnboundKey(OCSEnterpriseObject.groovy:1173)
 at 
 com.webobjects.foundation.NSKeyValueCoding$Utility.handleQueryWithUnboundKey(NSKeyValueCoding.java:494)
 at 
 com.webobjects.foundation.NSKeyValueCoding$_KeyBinding.valueInObject(NSKeyValueCoding.java:894)
 at 
 com.webobjects.eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.java:1634)
 at com.webobjects.eocontrol.EOKeyValueCoding$storedValueForKey.call(Unknown 
 Source)
 at cz.ocs.model.OCSEOUtilities$FOO_ACCESSOR(OCSEOUtilities.groovy:60)
 ...
 at 
 cz.ocs.model.OCSEnterpriseObject.handleQueryWithUnboundKey(OCSEnterpriseObject.groovy:1173)
 ...
 ===
 It even is documented thus, EOCustomObject.storedValueForKey tries first _foo 
 and foo, then... yadda yadda ... and if all fails, it is documented to go 
 handleTakeValueForUnboundKey (which seems to be a typo in documentation, 
 meaning handleQueryWithUnboundKey instead):
 ===
 ...
 public Object storedValueForKey(String key)
 Returns the value for the property identified by key. This method is used 
 when the value is retrieved for storage in an object store (generally, this 
 is ultimately in a database) or for inclusion in a snapshot. The default 
 implementation provided by EOCustomObject is similar to the implementation of 
 valueForKey, but it resolveskey with a different method instance variable 
 search order:
 • Searches for a private accessor method based on key (a method preceded by 
 an underbar). For example, with a key of lastName, storedValueForKey looks 
 for a method named _getLastName or _lastName.
 • If a private accessor isn't found, searches for an instance variable based 
 on key and returns its value directly. For example, with a key of 
 lastName,storedValueForKey looks for an instance variable named _lastName 
 or lastName.
 • If neither a private accessor or an instance variable is found, 
 storedValueForKey searches for a public accessor method based on key. For the 
 key lastName, this would be getLastName or lastName.
 • If key is unknown, storedValueForKey calls handleTakeValueForUnboundKey.
 ...
 ===
 But darn, _where_ then is the specific EOF code to get the attribute value 
 from snapshot/from database? So far I thought EOCustomObject overrides the 
 generic storedValueForKey appropriately (so that instead of trying _foo, 
 _getFoo, foo and getFoo it reads from snapshot/database). It does not seem 
 to, though?!?
 What am I missing here?!?
 Thanks a lot,
 OC
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/chill%40gevityinc.com
 
 This email sent to ch...@gevityinc.com


 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev 

Re: D2w - toMany relation

2015-01-12 Thread Theodore Petrosky
Keep in mind that there are lots of WOConditionals that you can access. I would 
hope that you have the Wonder source, and you can look at the components and 
get the conditional. in this case in ERMODEditRelationshipPage  in the WOD is:

ShowFind: WOConditional {
condition = d2wContext.shouldShowQueryRelatedButton;
}

I find that you must begin looking through the source of D2W to find all these 
hidden jewels.

Ted


On Jan 12, 2015, at 5:48 AM, Pierre Gilquin pgilq...@citycable.ch wrote:

 Hi,
 
 
 I have a tomany relation very similar to the RentalHistory relation in Movie 
 DB (Customer - RentalHistory - Movie).
 I created an Wonder D2W Application with my model and that's already very 
 good.
 
 But the component used for the relation use 2 buttons Search and New.
 How can I get rid of the Search button as there is no meaning to transfer a 
 rental from a cutomer to an other ?
 
 The New bouton is ok except I think that it should be Add  How can I 
 change that ?
 
 
 
 Thanks in advance
 
 
 Pierre
 
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/tedpet5%40yahoo.com
 
 This email sent to tedp...@yahoo.com


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

This email sent to arch...@mail-archive.com

Re: D2w - toMany relation

2015-01-12 Thread Flavio Donadio
Pierre,


Try this simple rule (took me some time to find the first time I needed this):

100 : pageConfiguration like 'EditRelationshipEmbeddedRentalHistory' = 
shouldShowQueryRelatedButton = false 
[com.webobjects.directtoweb.BooleanAssignment]


Cheers,
Flavio

On 12/01/2015, at 08:48, Pierre Gilquin pgilq...@citycable.ch wrote:

 Hi,
 
 
 I have a tomany relation very similar to the RentalHistory relation in Movie 
 DB (Customer - RentalHistory - Movie).
 I created an Wonder D2W Application with my model and that's already very 
 good.
 
 But the component used for the relation use 2 buttons Search and New.
 How can I get rid of the Search button as there is no meaning to transfer a 
 rental from a cutomer to an other ?
 
 The New bouton is ok except I think that it should be Add  How can I 
 change that ?
 
 
 
 Thanks in advance
 
 
 Pierre
 
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/flavio%40donadio.com.br
 
 This email sent to fla...@donadio.com.br


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

This email sent to arch...@mail-archive.com

D2w - toMany relation

2015-01-12 Thread Pierre Gilquin

Hi,


I have a tomany relation very similar to the RentalHistory relation in 
Movie DB (Customer - RentalHistory - Movie).
I created an Wonder D2W Application with my model and that's already 
very good.


But the component used for the relation use 2 buttons Search and New.
How can I get rid of the Search button as there is no meaning to 
transfer a rental from a cutomer to an other ?


The New bouton is ok except I think that it should be Add  How can 
I change that ?




Thanks in advance


Pierre



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

This email sent to arch...@mail-archive.com

Re: ERXSQLHelper

2015-01-12 Thread OC
Theodore,

On 12. 1. 2015, at 19:00, Theodore Petrosky tedp...@yahoo.com wrote:
 have you looked at the migrations? 
 ERXMigrationTable personTable = database.existingTableNamed(person);
 personTable.existingColumnNamed(Foo).renameTo(Bar”);
 personTable.newStringColumn(name, width, allowsNull)

well... the API looks OK, but in practice it does not seem quite work. Can you 
(or anybody knowledgeable) please point out what am I doing wrong? Here's my 
code (sans error checking etc. for better readability)

===
EOObjectStoreCoordinator 
osc=EOObjectStoreCoordinator.defaultCoordinator()
EODatabaseContext 
ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
ctxt.lock();
try {
EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
if (!ach.isOpen()) ach.openChannel();
def tables=ach.describeTableNames() // looks like Migration API 
does not read the current state reliably
EOModel dbModel=ach.describeModelWithTableNames(tables)
ERXMigrationDatabase mdb=nil // created on-demand
mdg.models.each { EOModel localModel -
localModel.entities.each { EOEntity localEntity -
if (localEntity.isAbstractEntity()) return
String tname=localEntity.externalName()
EOEntity dbEntity=dbModel.entityNamed(tname)
ERXMigrationTable mtable=nil // on-demand
localEntity.attributes.each { EOAttribute localAttribute -
String cname=localAttribute.columnName()
EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
if (!dbAttribute) {
println   adding column $cname 
($localAttribute.name): $localAttribute.externalType (VT: 
$localAttribute.valueType) ...
if (!mdb) mdb=ERXMigrationDatabase.database(ach)
if (!mtable) mtable=mdb.existingTableNamed(tname)
switch (localAttribute.externalType) {
...
case 'TIMESTAMP':
mtable.newTimestampColumn(cname,YES)
break
}
println   - OK
}
}
}
}
} finally {
ctxt.unlock()
}
===

but it crashes, printing out

===
  adding column DC_ID (ID): TIMESTAMP (VT: null) ...
22:42:09.409 INFO  Executing alter table T_AUCTION null DC_ID TIMESTAMP   
//log:er.extensions.jdbc.ERXJDBCUtilities [main]
...
Caused by: java.lang.RuntimeException: Failed to execute 'alter table T_AUCTION 
null DC_ID TIMESTAMP'.
Caused by: java.sql.SQLException: Syntax error 179. Illegal ALTER TABLE 
statement.
===

Well self-evidently it _is_ an illegal statement, it lacks add column having 
null instead; but what's the culprit and how to fix the problem?

(Note: I've tried to bump up log levels to
log4j.logger.er.extensions.jdbc.ERXJDBCUtilities=TRACE
log4j.logger.er.extensions.migration.ERXMigrationDatabase=TRACE
log4j.logger.er.extensions.migration.ERXMigrationTable=TRACE
log4j.logger.er.extensions.migration.ERXMigrationColumn=TRACE
but no more logs occurred anyway.)

Thanks,
OC


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

This email sent to arch...@mail-archive.com

Re: ERXSQLHelper

2015-01-12 Thread OC
P.S. my current environment is

Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 / 
Mac OS X 10.8.5 / FrontBase 7.2

On 12. 1. 2015, at 22:56, OC o...@ocs.cz wrote:

 Theodore,
 
 On 12. 1. 2015, at 19:00, Theodore Petrosky tedp...@yahoo.com wrote:
 have you looked at the migrations? 
 ERXMigrationTable personTable = database.existingTableNamed(person);
 personTable.existingColumnNamed(Foo).renameTo(Bar”);
 personTable.newStringColumn(name, width, allowsNull)
 
 well... the API looks OK, but in practice it does not seem quite work. Can 
 you (or anybody knowledgeable) please point out what am I doing wrong? Here's 
 my code (sans error checking etc. for better readability)
 
 ===
EOObjectStoreCoordinator 
 osc=EOObjectStoreCoordinator.defaultCoordinator()
EODatabaseContext 
 ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
ctxt.lock();
try {
EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
if (!ach.isOpen()) ach.openChannel();
def tables=ach.describeTableNames() // looks like Migration API 
 does not read the current state reliably
EOModel dbModel=ach.describeModelWithTableNames(tables)
ERXMigrationDatabase mdb=nil // created on-demand
mdg.models.each { EOModel localModel -
localModel.entities.each { EOEntity localEntity -
if (localEntity.isAbstractEntity()) return
String tname=localEntity.externalName()
EOEntity dbEntity=dbModel.entityNamed(tname)
ERXMigrationTable mtable=nil // on-demand
localEntity.attributes.each { EOAttribute localAttribute -
String cname=localAttribute.columnName()
EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
if (!dbAttribute) {
println   adding column $cname 
 ($localAttribute.name): $localAttribute.externalType (VT: 
 $localAttribute.valueType) ...
if (!mdb) mdb=ERXMigrationDatabase.database(ach)
if (!mtable) mtable=mdb.existingTableNamed(tname)
switch (localAttribute.externalType) {
 ...
case 'TIMESTAMP':
mtable.newTimestampColumn(cname,YES)
break
}
println   - OK
}
}
}
}
} finally {
ctxt.unlock()
}
 ===
 
 but it crashes, printing out
 
 ===
  adding column DC_ID (ID): TIMESTAMP (VT: null) ...
 22:42:09.409 INFO  Executing alter table T_AUCTION null DC_ID TIMESTAMP   
 //log:er.extensions.jdbc.ERXJDBCUtilities [main]
 ...
 Caused by: java.lang.RuntimeException: Failed to execute 'alter table 
 T_AUCTION null DC_ID TIMESTAMP'.
 Caused by: java.sql.SQLException: Syntax error 179. Illegal ALTER TABLE 
 statement.
 ===
 
 Well self-evidently it _is_ an illegal statement, it lacks add column 
 having null instead; but what's the culprit and how to fix the problem?
 
 (Note: I've tried to bump up log levels to
 log4j.logger.er.extensions.jdbc.ERXJDBCUtilities=TRACE
 log4j.logger.er.extensions.migration.ERXMigrationDatabase=TRACE
 log4j.logger.er.extensions.migration.ERXMigrationTable=TRACE
 log4j.logger.er.extensions.migration.ERXMigrationColumn=TRACE
 but no more logs occurred anyway.)
 
 Thanks,
 OC
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/ocs%40ocs.cz
 
 This email sent to o...@ocs.cz


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

This email sent to arch...@mail-archive.com

Re: ERXSQLHelper

2015-01-12 Thread Paul Hoadley
On 13 Jan 2015, at 10:01 am, OC o...@ocs.cz wrote:

 Just my 2¢, but instead of that large block of code, why not just change 
 some properties, run migrations at app startup, and declare your changes 
 there? Migrations work and you don’t have to reinvent the wheel. Then, if 
 your SQL continues to be incorrect, you know where to focus. 
 
 Can you please point me to some howto? To be frank, I have absolutely no idea 
 what “migration” is.

Start here:

http://jenkins.wocommunity.org/job/Wonder/lastSuccessfulBuild/javadoc/er/extensions/migration/package-summary.html

 Consider my current case -- I need to sync tables to model /more details 
 below/, and perhaps I'm just dumb, but migration is about the very last 
 word I would search for, to fulfill that need?!? I don't migrate anything to 
 anywhere; all I need is to synchronize the database to the model.

Migrations will do that, though it's completely manual in that you provide Java 
code to migrate the database from its existing state to a new state where it 
reflects changes you've made to the model.


-- 
Paul Hoadley
http://logicsquad.net/



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

This email sent to arch...@mail-archive.com

Re: ERXSQLHelper

2015-01-12 Thread Theodore Petrosky
thanks chuck, i have gotten so used to Migrations  that I couldn’t find the 
docs. I don’t know how to do this without migrations, this is fantastic.


On Jan 12, 2015, at 6:37 PM, Chuck Hill ch...@gevityinc.com wrote:

 
 
 On 2015-01-12, 3:31 PM, OC wrote:
 
 Tim,
 
 On 12. 1. 2015, at 23:59, Timothy Worman li...@thetimmy.com wrote:
 
 I don’t know how far you’ve dug - but just in case I’ll throw this out. One 
 of the keys to how all this works is ERXSQLHelper sqlHelper = 
 ERXSQLHelper.newSQLHelper. This returns the vendor specific ERXSQLHelper for 
 your database (Frontbase). DB specific code is there.
 
 Where do I set this up for the ERXMigration* stuff? There does not seem to be 
 any place for me to set this up.
 
 ERXSQLHelper was the first place I have looked, but I haven't found there 
 anything related to adding (and removing/renaming) columns, only stuff 
 related to whole entities/tables. Perhaps I did look wrong.
 
 Just my 2¢, but instead of that large block of code, why not just change some 
 properties, run migrations at app startup, and declare your changes there? 
 Migrations work and you don’t have to reinvent the wheel. Then, if your SQL 
 continues to be incorrect, you know where to focus.
 
 Can you please point me to some howto? To be frank, I have absolutely no idea 
 what “migration” is. (Truth is, I must be missing something pretty obvious at 
 the documentation side: whilst I can find my way in WOnder if I know what 
 exactly to search for, so far, I haven't found anything which would help me 
 to find a support for some general functionality, unless 'find wonderdoc | 
 xargs fgrep thedesiredthing' helps, which it very often does not. Consider my 
 current case -- I need to sync tables to model /more details below/, and 
 perhaps I'm just dumb, but migration is about the very last word I would 
 search for, to fulfill that need?!? I don't migrate anything to anywhere; all 
 I need is to synchronize the database to the model.)
 
 *cough* JavaDoc
 
 https://github.com/wocommunity/wonder/blob/master/Frameworks/Core/ERExtensions/Sources/er/extensions/migration/package.html
 
 
 
 Anyway, my workflow is this
 
 (a) I open the database and read from there some dynamic information (works 
 OK)
 (b) based on this information, I add a number of dynamic EOAttributes to my 
 model (works OK too)
 (c) at this moment, I need to sync the DB and model, namely
 - adding columns to the database for EOAttributes which do not have any
 - removing colums from the database for which there are no EOAttributes
 - removing and re-adding columns for which there are EOAttributes of an 
 incompatible kind
 
 If the migration thing can do this, it would be just great.
 
 Migrations is only intended to run at a very early place in app startup.
 
 Chuck
 
 
 
 Thanks a big lot,
 OC
 
 On Jan 12, 2015, at 2:18 PM, OC o...@ocs.cz wrote:
 P.S. my current environment is
 Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 
 / Mac OS X 10.8.5 / FrontBase 7.2
 On 12. 1. 2015, at 22:56, OC o...@ocs.cz wrote:
 Theodore,
 On 12. 1. 2015, at 19:00, Theodore Petrosky tedp...@yahoo.com wrote:
 have you looked at the migrations?
 ERXMigrationTable personTable = database.existingTableNamed(person);
 personTable.existingColumnNamed(Foo).renameTo(Bar”);
 personTable.newStringColumn(name, width, allowsNull)
 well... the API looks OK, but in practice it does not seem quite work. Can 
 you (or anybody knowledgeable) please point out what am I doing wrong? Here's 
 my code (sans error checking etc. for better readability)
 ===
   EOObjectStoreCoordinator 
 osc=EOObjectStoreCoordinator.defaultCoordinator()
   EODatabaseContext 
 ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
   ctxt.lock();
   try {
   EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
   if (!ach.isOpen()) ach.openChannel();
   def tables=ach.describeTableNames() // looks like Migration API 
 does not read the current state reliably
   EOModel dbModel=ach.describeModelWithTableNames(tables)
   ERXMigrationDatabase mdb=nil // created on-demand
   mdg.models.each { EOModel localModel -
   localModel.entities.each { EOEntity localEntity -
   if (localEntity.isAbstractEntity()) return
   String tname=localEntity.externalName()
   EOEntity dbEntity=dbModel.entityNamed(tname)
   ERXMigrationTable mtable=nil // on-demand
   localEntity.attributes.each { EOAttribute localAttribute -
   String cname=localAttribute.columnName()
   EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
   if (!dbAttribute) {
   println   adding column $cname 
 ($localAttribute.name): $localAttribute.externalType (VT: 
 $localAttribute.valueType) ...
   if (!mdb) 

Re: ERXSQLHelper

2015-01-12 Thread OC
Tim,

On 12. 1. 2015, at 23:59, Timothy Worman li...@thetimmy.com wrote:

 I don’t know how far you’ve dug - but just in case I’ll throw this out. One 
 of the keys to how all this works is ERXSQLHelper sqlHelper = 
 ERXSQLHelper.newSQLHelper. This returns the vendor specific ERXSQLHelper for 
 your database (Frontbase). DB specific code is there.

Where do I set this up for the ERXMigration* stuff? There does not seem to be 
any place for me to set this up.

ERXSQLHelper was the first place I have looked, but I haven't found there 
anything related to adding (and removing/renaming) columns, only stuff related 
to whole entities/tables. Perhaps I did look wrong.

 Just my 2¢, but instead of that large block of code, why not just change some 
 properties, run migrations at app startup, and declare your changes there? 
 Migrations work and you don’t have to reinvent the wheel. Then, if your SQL 
 continues to be incorrect, you know where to focus. 

Can you please point me to some howto? To be frank, I have absolutely no idea 
what “migration” is. (Truth is, I must be missing something pretty obvious at 
the documentation side: whilst I can find my way in WOnder if I know what 
exactly to search for, so far, I haven't found anything which would help me to 
find a support for some general functionality, unless 'find wonderdoc | xargs 
fgrep thedesiredthing' helps, which it very often does not. Consider my current 
case -- I need to sync tables to model /more details below/, and perhaps I'm 
just dumb, but migration is about the very last word I would search for, to 
fulfill that need?!? I don't migrate anything to anywhere; all I need is to 
synchronize the database to the model.)

Anyway, my workflow is this

(a) I open the database and read from there some dynamic information (works OK)
(b) based on this information, I add a number of dynamic EOAttributes to my 
model (works OK too)
(c) at this moment, I need to sync the DB and model, namely
- adding columns to the database for EOAttributes which do not have any
- removing colums from the database for which there are no EOAttributes
- removing and re-adding columns for which there are EOAttributes of an 
incompatible kind

If the migration thing can do this, it would be just great.

Thanks a big lot,
OC

 On Jan 12, 2015, at 2:18 PM, OC o...@ocs.cz wrote:
 
 P.S. my current environment is
 
 Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 
 1.7.0_13 / Mac OS X 10.8.5 / FrontBase 7.2
 
 On 12. 1. 2015, at 22:56, OC o...@ocs.cz wrote:
 
 Theodore,
 
 On 12. 1. 2015, at 19:00, Theodore Petrosky tedp...@yahoo.com wrote:
 have you looked at the migrations? 
 ERXMigrationTable personTable = database.existingTableNamed(person);
 personTable.existingColumnNamed(Foo).renameTo(Bar”);
 personTable.newStringColumn(name, width, allowsNull)
 
 well... the API looks OK, but in practice it does not seem quite work. Can 
 you (or anybody knowledgeable) please point out what am I doing wrong? 
 Here's my code (sans error checking etc. for better readability)
 
 ===
  EOObjectStoreCoordinator 
 osc=EOObjectStoreCoordinator.defaultCoordinator()
  EODatabaseContext 
 ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
  ctxt.lock();
  try {
  EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
  if (!ach.isOpen()) ach.openChannel();
  def tables=ach.describeTableNames() // looks like Migration API 
 does not read the current state reliably
  EOModel dbModel=ach.describeModelWithTableNames(tables)
  ERXMigrationDatabase mdb=nil // created on-demand
  mdg.models.each { EOModel localModel -
  localModel.entities.each { EOEntity localEntity -
  if (localEntity.isAbstractEntity()) return
  String tname=localEntity.externalName()
  EOEntity dbEntity=dbModel.entityNamed(tname)
  ERXMigrationTable mtable=nil // on-demand
  localEntity.attributes.each { EOAttribute localAttribute -
  String cname=localAttribute.columnName()
  EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
  if (!dbAttribute) {
  println   adding column $cname 
 ($localAttribute.name): $localAttribute.externalType (VT: 
 $localAttribute.valueType) ...
  if (!mdb) mdb=ERXMigrationDatabase.database(ach)
  if (!mtable) mtable=mdb.existingTableNamed(tname)
  switch (localAttribute.externalType) {
 ...
  case 'TIMESTAMP':
  mtable.newTimestampColumn(cname,YES)
  break
  }
  println   - OK
  }
  }
  }
  }
  } finally {
  ctxt.unlock()
  }
 ===
 
 but 

Model/DB synchronization (was: Migrations (was: ERXSQLHelper))

2015-01-12 Thread OC
Paul, Chuck, Theodore, Timothy, and others,

On 13. 1. 2015, at 1:02, Paul Hoadley pa...@logicsquad.net wrote:
 But after first going through I am none the smarter and it does not seem to 
 me it would help. Perhaps I am completely missing the point, but seems to me 
 this is intended to a completely different task than the one of mine?
 
 It might be just solving the same problem differently.  What you've described 
 as your workflow seems fairly dynamic (reading the database, adding 
 properties at runtime, adding and removing columns, and so on), and 
 migrations as implemented in er.extensions.migration are not at all dynamic: 
 you manually keep the database in sync with changes to the model using Java 
 code that is run (if required) at application startup.

Now I have re-readed the docs a couple of times, and it seems to me

(a) I have to mark different schemas as versions;
(b) I have to write basic Java code for each supported version, which code 
(could do about anything, but normally) just loads and executes a script 
containing all the CREATE TABLE/ADD COLUMN/whatever SQL stuff needed;
(c) I have to write those scripts.

Then, WOnder migrations support keeps track of DB versions for me and makes 
sure appropriate Java upgrade method of appropriate class for a given model 
gets called (which normally means the appropriate script performed), based on 
the current and desired DB version.

If my perception is right, this is definitely what I don't want here. I don't 
need to manage different versions for lots of models. I would have anyway to 
generate those SQL scripts of (c) programmatically, or else, to write a code 
which scans my model and calls appropriate add-columns in (b).

Which is exactly what I am struggling with anyway, and perhaps I'm just blind, 
but I can't see much migrations would help me with. They would make sure 
appropriate code is called for given version -- but I have only _one_ code for 
_one_ version. And I would have to write the code -- just as I have to now.

 Well... this version of my app _does_ do that at startup only, but future 
 versions definitely should be able to re-read the data -- (a) -- and re-do 
 the synchronization of model -- (b) -- and database -- (c) -- essentially at 
 any time (of course, locking completely out all other instances when it is 
 being done).
 
 I really don't know if Wonder migrations are going to solve your particular 
 use case, but it's certainly worth a look.  If you need the two-way 
 synchronisation you describe (that is, from database back to model as well), 
 then migrations are not going to help you.  It's strictly one way: model to 
 database via Java.

Just again, my task is

(i) to determine the desired schema -- it is partially defined by static model, 
partially defined by stuff stored in the database itself. So, the first thing I 
need is to read some tables, and based on their contents to create my schema 
dynamically. The thing is considerably more complex, but as a simplified 
example, presume there's a T_SCHEMA table with C_TNAME, C_CNAME and C_CTYPE 
columns; my code would read its contents, and for each row, it would know in 
the dynamic scheme, the table whose name is stored in C_TNAME should contain a 
column whose name is stored in C_CNAME and type in C_CTYPE.

(ii) having read in the data and having constructed the desired schema, I 
update my model appropriately. This part is comparatively easy -- given the 
simplified example above, I just go through all the C_TNAMEs, for each of them 
find appropriate entity in my model (I do not create tables dynamically, only 
columns, which mean I always find the entity). Then I go through all the 
C_CNAMEs with the same C_TNAME, and for each of them add appropriate 
EOAttribute. This (after some struggle with the new EOAttribute(entity) gotcha) 
works quite well.

(iii) having created the desired schema in my model, I need to sync the model 
to the database.

Note: this is one model, not a network of models. (Well I have got two of them 
in fact, but that's unimportant technicality.) There are no static versions; 
there are just static tables and static columns (defined in the model as read 
in from eomodeld), plust dynamic attributes defined by contents of the database 
itself -- those were added to the model programmatically at (ii).

And those programmatically added attributes now need to be synchronized to the 
database as columns.

The task is, therefore, as follows:

(a) I have to read in the current database schema;
(b) I have to go through all the dynamically added attributes, and check 
whether they do have appropriate column in the database
- if they do, all right (presumably this dynamic attribute has been added long 
ago and already synced to DB), nothing to do;
- if they do not (this very attribute has been added lately, after last sync) 
-- I have to create appropriate column.

For simplicity let's forget the remaining cases (extra column in DB -- whose 

Re: ERXSQLHelper

2015-01-12 Thread Chuck Hill


On 2015-01-12, 3:31 PM, OC wrote:

Tim,

On 12. 1. 2015, at 23:59, Timothy Worman 
li...@thetimmy.commailto:li...@thetimmy.com wrote:

I don’t know how far you’ve dug - but just in case I’ll throw this out. One of 
the keys to how all this works is ERXSQLHelper sqlHelper = 
ERXSQLHelper.newSQLHelper. This returns the vendor specific ERXSQLHelper for 
your database (Frontbase). DB specific code is there.

Where do I set this up for the ERXMigration* stuff? There does not seem to be 
any place for me to set this up.

ERXSQLHelper was the first place I have looked, but I haven't found there 
anything related to adding (and removing/renaming) columns, only stuff related 
to whole entities/tables. Perhaps I did look wrong.

Just my 2¢, but instead of that large block of code, why not just change some 
properties, run migrations at app startup, and declare your changes there? 
Migrations work and you don’t have to reinvent the wheel. Then, if your SQL 
continues to be incorrect, you know where to focus.

Can you please point me to some howto? To be frank, I have absolutely no idea 
what “migration” is. (Truth is, I must be missing something pretty obvious at 
the documentation side: whilst I can find my way in WOnder if I know what 
exactly to search for, so far, I haven't found anything which would help me to 
find a support for some general functionality, unless 'find wonderdoc | xargs 
fgrep thedesiredthing' helps, which it very often does not. Consider my current 
case -- I need to sync tables to model /more details below/, and perhaps I'm 
just dumb, but migration is about the very last word I would search for, to 
fulfill that need?!? I don't migrate anything to anywhere; all I need is to 
synchronize the database to the model.)

*cough* JavaDoc

https://github.com/wocommunity/wonder/blob/master/Frameworks/Core/ERExtensions/Sources/er/extensions/migration/package.html



Anyway, my workflow is this

(a) I open the database and read from there some dynamic information (works OK)
(b) based on this information, I add a number of dynamic EOAttributes to my 
model (works OK too)
(c) at this moment, I need to sync the DB and model, namely
- adding columns to the database for EOAttributes which do not have any
- removing colums from the database for which there are no EOAttributes
- removing and re-adding columns for which there are EOAttributes of an 
incompatible kind

If the migration thing can do this, it would be just great.

Migrations is only intended to run at a very early place in app startup.

Chuck



Thanks a big lot,
OC

On Jan 12, 2015, at 2:18 PM, OC o...@ocs.czmailto:o...@ocs.cz wrote:
P.S. my current environment is
Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 / 
Mac OS X 10.8.5 / FrontBase 7.2
On 12. 1. 2015, at 22:56, OC o...@ocs.czmailto:o...@ocs.cz wrote:
Theodore,
On 12. 1. 2015, at 19:00, Theodore Petrosky 
tedp...@yahoo.commailto:tedp...@yahoo.com wrote:
have you looked at the migrations?
ERXMigrationTable personTable = database.existingTableNamed(person);
personTable.existingColumnNamed(Foo).renameTo(Bar”);
personTable.newStringColumn(name, width, allowsNull)
well... the API looks OK, but in practice it does not seem quite work. Can you 
(or anybody knowledgeable) please point out what am I doing wrong? Here's my 
code (sans error checking etc. for better readability)
===
  EOObjectStoreCoordinator osc=EOObjectStoreCoordinator.defaultCoordinator()
  EODatabaseContext 
ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
  ctxt.lock();
  try {
  EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
  if (!ach.isOpen()) ach.openChannel();
  def tables=ach.describeTableNames() // looks like Migration API does 
not read the current state reliably
  EOModel dbModel=ach.describeModelWithTableNames(tables)
  ERXMigrationDatabase mdb=nil // created on-demand
  mdg.models.each { EOModel localModel -
  localModel.entities.each { EOEntity localEntity -
  if (localEntity.isAbstractEntity()) return
  String tname=localEntity.externalName()
  EOEntity dbEntity=dbModel.entityNamed(tname)
  ERXMigrationTable mtable=nil // on-demand
  localEntity.attributes.each { EOAttribute localAttribute -
  String cname=localAttribute.columnName()
  EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
  if (!dbAttribute) {
  println   adding column $cname 
($localAttribute.name): $localAttribute.externalType (VT: 
$localAttribute.valueType) ...
  if (!mdb) mdb=ERXMigrationDatabase.database(ach)
  if (!mtable) mtable=mdb.existingTableNamed(tname)
  switch (localAttribute.externalType) {
...
  case 'TIMESTAMP':
 

Re: Migrations (was: ERXSQLHelper)

2015-01-12 Thread Paul Hoadley
On 13 Jan 2015, at 10:16 am, OC o...@ocs.cz wrote:

 But after first going through I am none the smarter and it does not seem to 
 me it would help. Perhaps I am completely missing the point, but seems to me 
 this is intended to a completely different task than the one of mine?

It might be just solving the same problem differently.  What you've described 
as your workflow seems fairly dynamic (reading the database, adding properties 
at runtime, adding and removing columns, and so on), and migrations as 
implemented in er.extensions.migration are not at all dynamic: you manually 
keep the database in sync with changes to the model using Java code that is run 
(if required) at application startup.

 Might be wrong, so far, I do not quite get what the migration stuff does, not 
 speaking of the slightest idea how could I exploit it. I do not have versions 
 (unless you simply define „any change in DB makes a new version“, in which 
 case of course I have them, but this does not seem to help),

A version for the purposes of migrations means any change to the model 
between re-deployments.  (How it works in real life is somewhat dependent on 
your development/deployment methodology.  You could certainly make a bunch of 
changes to the model over time, but package them into a single migration class 
to run against the production database next time you deploy.)

 and I neither upgrade nor downgrade anything.

It's just arbitrary terminology—you upgrade the database to reflect changes 
to the model.  Theoretically you could downgrade the database to revert to an 
earlier version of the model, though that functionality was never implemented 
anyway.

 Well... this version of my app _does_ do that at startup only, but future 
 versions definitely should be able to re-read the data -- (a) -- and re-do 
 the synchronization of model -- (b) -- and database -- (c) -- essentially at 
 any time (of course, locking completely out all other instances when it is 
 being done).

I really don't know if Wonder migrations are going to solve your particular use 
case, but it's certainly worth a look.  If you need the two-way synchronisation 
you describe (that is, from database back to model as well), then migrations 
are not going to help you.  It's strictly one way: model to database via Java.


-- 
Paul Hoadley
http://logicsquad.net/



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

This email sent to arch...@mail-archive.com

Re: ERXSQLHelper

2015-01-12 Thread Timothy Worman
OC:

I don’t know how far you’ve dug - but just in case I’ll throw this out. One of 
the keys to how all this works is ERXSQLHelper sqlHelper = 
ERXSQLHelper.newSQLHelper. This returns the vendor specific ERXSQLHelper for 
your database (Frontbase). DB specific code is there.

You might want to check the inner class:

public static class FrontBaseSQLHelper extends ERXSQLHelper

Just my 2¢, but instead of that large block of code, why not just change some 
properties, run migrations at app startup, and declare your changes there? 
Migrations work and you don’t have to reinvent the wheel. Then, if your SQL 
continues to be incorrect, you know where to focus. 

Tim Worman
UCLA GSEIS


 On Jan 12, 2015, at 2:18 PM, OC o...@ocs.cz wrote:
 
 P.S. my current environment is
 
 Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 
 / Mac OS X 10.8.5 / FrontBase 7.2
 
 On 12. 1. 2015, at 22:56, OC o...@ocs.cz wrote:
 
 Theodore,
 
 On 12. 1. 2015, at 19:00, Theodore Petrosky tedp...@yahoo.com wrote:
 have you looked at the migrations? 
 ERXMigrationTable personTable = database.existingTableNamed(person);
 personTable.existingColumnNamed(Foo).renameTo(Bar”);
 personTable.newStringColumn(name, width, allowsNull)
 
 well... the API looks OK, but in practice it does not seem quite work. Can 
 you (or anybody knowledgeable) please point out what am I doing wrong? 
 Here's my code (sans error checking etc. for better readability)
 
 ===
   EOObjectStoreCoordinator 
 osc=EOObjectStoreCoordinator.defaultCoordinator()
   EODatabaseContext 
 ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
   ctxt.lock();
   try {
   EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
   if (!ach.isOpen()) ach.openChannel();
   def tables=ach.describeTableNames() // looks like Migration API 
 does not read the current state reliably
   EOModel dbModel=ach.describeModelWithTableNames(tables)
   ERXMigrationDatabase mdb=nil // created on-demand
   mdg.models.each { EOModel localModel -
   localModel.entities.each { EOEntity localEntity -
   if (localEntity.isAbstractEntity()) return
   String tname=localEntity.externalName()
   EOEntity dbEntity=dbModel.entityNamed(tname)
   ERXMigrationTable mtable=nil // on-demand
   localEntity.attributes.each { EOAttribute localAttribute -
   String cname=localAttribute.columnName()
   EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
   if (!dbAttribute) {
   println   adding column $cname 
 ($localAttribute.name): $localAttribute.externalType (VT: 
 $localAttribute.valueType) ...
   if (!mdb) mdb=ERXMigrationDatabase.database(ach)
   if (!mtable) mtable=mdb.existingTableNamed(tname)
   switch (localAttribute.externalType) {
 ...
   case 'TIMESTAMP':
   mtable.newTimestampColumn(cname,YES)
   break
   }
   println   - OK
   }
   }
   }
   }
   } finally {
   ctxt.unlock()
   }
 ===
 
 but it crashes, printing out
 
 ===
 adding column DC_ID (ID): TIMESTAMP (VT: null) ...
 22:42:09.409 INFO  Executing alter table T_AUCTION null DC_ID TIMESTAMP  
  //log:er.extensions.jdbc.ERXJDBCUtilities [main]
 ...
 Caused by: java.lang.RuntimeException: Failed to execute 'alter table 
 T_AUCTION null DC_ID TIMESTAMP'.
 Caused by: java.sql.SQLException: Syntax error 179. Illegal ALTER TABLE 
 statement.
 ===
 
 Well self-evidently it _is_ an illegal statement, it lacks add column 
 having null instead; but what's the culprit and how to fix the problem?
 
 (Note: I've tried to bump up log levels to
 log4j.logger.er.extensions.jdbc.ERXJDBCUtilities=TRACE
 log4j.logger.er.extensions.migration.ERXMigrationDatabase=TRACE
 log4j.logger.er.extensions.migration.ERXMigrationTable=TRACE
 log4j.logger.er.extensions.migration.ERXMigrationColumn=TRACE
 but no more logs occurred anyway.)
 
 Thanks,
 OC
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/ocs%40ocs.cz
 
 This email sent to o...@ocs.cz
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/lists%40thetimmy.com
 
 This email sent to 

Migrations (was: ERXSQLHelper)

2015-01-12 Thread OC
Chuck,

On 13. 1. 2015, at 0:37, Chuck Hill ch...@gevityinc.com wrote:

 Can you please point me to some howto? To be frank, I have absolutely no 
 idea what “migration” is. (Truth is, I must be missing something pretty 
 obvious at the documentation side: whilst I can find my way in WOnder if I 
 know what exactly to search for, so far, I haven't found anything which 
 would help me to find a support for some general functionality, unless 'find 
 wonderdoc | xargs fgrep thedesiredthing' helps, which it very often does 
 not. Consider my current case -- I need to sync tables to model /more 
 details below/, and perhaps I'm just dumb, but migration is about the very 
 last word I would search for, to fulfill that need?!? I don't migrate 
 anything to anywhere; all I need is to synchronize the database to the 
 model.)
 
 *cough* JavaDoc
 
 https://github.com/wocommunity/wonder/blob/master/Frameworks/Core/ERExtensions/Sources/er/extensions/migration/package.html

Well meantime I've googled out 
http://webobjects.mdimension.com/hudson/job/Wonder/javadoc/er/extensions/migration/package-summary.html
 which looks like the very same doc, just readable :)

But after first going through I am none the smarter and it does not seem to me 
it would help. Perhaps I am completely missing the point, but seems to me this 
is intended to a completely different task than the one of mine? Might be 
wrong, so far, I do not quite get what the migration stuff does, not speaking 
of the slightest idea how could I exploit it. I do not have versions (unless 
you simply define „any change in DB makes a new version“, in which case of 
course I have them, but this does not seem to help), and I neither upgrade 
nor downgrade anything.

 Anyway, my workflow is this
 
 (a) I open the database and read from there some dynamic information (works 
 OK)
 (b) based on this information, I add a number of dynamic EOAttributes to my 
 model (works OK too)
 (c) at this moment, I need to sync the DB and model, namely
 - adding columns to the database for EOAttributes which do not have any
 - removing colums from the database for which there are no EOAttributes
 - removing and re-adding columns for which there are EOAttributes of an 
 incompatible kind
 
 If the migration thing can do this, it would be just great.
 
 Migrations is only intended to run at a very early place in app startup.

Well... this version of my app _does_ do that at startup only, but future 
versions definitely should be able to re-read the data -- (a) -- and re-do the 
synchronization of model -- (b) -- and database -- (c) -- essentially at any 
time (of course, locking completely out all other instances when it is being 
done).

Thanks a lot,
OC

 On Jan 12, 2015, at 2:18 PM, OC o...@ocs.cz wrote:
 P.S. my current environment is
 Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 
 / Mac OS X 10.8.5 / FrontBase 7.2
 On 12. 1. 2015, at 22:56, OC o...@ocs.cz wrote:
 Theodore,
 On 12. 1. 2015, at 19:00, Theodore Petrosky tedp...@yahoo.com wrote:
 have you looked at the migrations?
 ERXMigrationTable personTable = database.existingTableNamed(person);
 personTable.existingColumnNamed(Foo).renameTo(Bar”);
 personTable.newStringColumn(name, width, allowsNull)
 well... the API looks OK, but in practice it does not seem quite work. Can 
 you (or anybody knowledgeable) please point out what am I doing wrong? Here's 
 my code (sans error checking etc. for better readability)
 ===
   EOObjectStoreCoordinator 
 osc=EOObjectStoreCoordinator.defaultCoordinator()
   EODatabaseContext 
 ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction')
   ctxt.lock();
   try {
   EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel();
   if (!ach.isOpen()) ach.openChannel();
   def tables=ach.describeTableNames() // looks like Migration API 
 does not read the current state reliably
   EOModel dbModel=ach.describeModelWithTableNames(tables)
   ERXMigrationDatabase mdb=nil // created on-demand
   mdg.models.each { EOModel localModel -
   localModel.entities.each { EOEntity localEntity -
   if (localEntity.isAbstractEntity()) return
   String tname=localEntity.externalName()
   EOEntity dbEntity=dbModel.entityNamed(tname)
   ERXMigrationTable mtable=nil // on-demand
   localEntity.attributes.each { EOAttribute localAttribute -
   String cname=localAttribute.columnName()
   EOAttribute dbAttribute=dbEntity.attributeNamed(cname)
   if (!dbAttribute) {
   println   adding column $cname 
 ($localAttribute.name): $localAttribute.externalType (VT: 
 $localAttribute.valueType) ...
   if (!mdb) mdb=ERXMigrationDatabase.database(ach)
   if (!mtable) 

maven.wocommunity.org is down

2015-01-12 Thread Faizel Dakri
Looks like the WOCommunity maven repo is down again. Can someone with access 
restart it?

Thanks,

F

-- 
Faizel Dakri
list...@dakri.com




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

This email sent to arch...@mail-archive.com

Re: Model/DB synchronization (was: Migrations (was: ERXSQLHelper))

2015-01-12 Thread Paul Hoadley
On 13 Jan 2015, at 12:06 pm, OC o...@ocs.cz wrote:

 Now I have re-readed the docs a couple of times, and it seems to me
 
 (a) I have to mark different schemas as versions;

It's really only conceptual.  A version is just a change to the model which 
I'm going to need to reflect in the database at the next deployment.

 (b) I have to write basic Java code for each supported version, which code 
 (could do about anything, but normally) just loads and executes a script 
 containing all the CREATE TABLE/ADD COLUMN/whatever SQL stuff needed;

You can do it that way, though I prefer using the migrations API in code.  
Except for some edge cases (such as, for example, adding a new mandatory column 
to a table in which there are existing rows), you needn't have any SQL at all.  
On the other hand, I understand there are people who do what you describe above 
with external scripts.

 (c) I have to write those scripts.

Entity Modeler can generate SQL for you from a model.  Alternatively, it will 
generate the initial migration code for you.  For _changes_ to a model, you can 
limit generation to a selected entity, but there's always some manual 
intervention required for both approaches.  You need to know what you're doing.

 Then, WOnder migrations support keeps track of DB versions for me and makes 
 sure appropriate Java upgrade method of appropriate class for a given model 
 gets called (which normally means the appropriate script performed), based on 
 the current and desired DB version.

Correct.

 If my perception is right, this is definitely what I don't want here.

Fair enough.

 I don't need to manage different versions for lots of models.

We don't use it that way either.  It's just for an ongoing linear progression 
where a new version just means the model changed.

 (i) to determine the desired schema -- it is partially defined by static 
 model, partially defined by stuff stored in the database itself. So, the 
 first thing I need is to read some tables, and based on their contents to 
 create my schema dynamically. The thing is considerably more complex, but as 
 a simplified example, presume there's a T_SCHEMA table with C_TNAME, C_CNAME 
 and C_CTYPE columns; my code would read its contents, and for each row, it 
 would know in the dynamic scheme, the table whose name is stored in C_TNAME 
 should contain a column whose name is stored in C_CNAME and type in C_CTYPE.

I agree that migrations is not going to help you with that.  That sounds like a 
pretty unique use case.  Out of curiosity, are you able to describe in greater 
depth what you're doing here?  (That is, the actual nature of the application, 
or the problem you're solving.  I understand your technical explanation, I just 
can't picture a use case for it.)  It sounds very interesting.


-- 
Paul Hoadley
http://logicsquad.net/



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

This email sent to arch...@mail-archive.com

ERXSQLHelper

2015-01-12 Thread OC
Hello there,

I need to generate add (and later also rename/drop) column SQL commands for 
given EOAttributes, like e.g.,

ALTER TABLE T_FOO ADD COLUMN C_BAR VARCHAR(256);

etc. So far, I haven't succeeded to find appropriate service in ERXSQLHelper 
(nor elsewhere): there seems to be dozen-odd methods to generate schema SQL for 
entities, but absolutely none for attributes. Am I just blind and there is an 
appropriate SQL generator somewhere in EOF/WOnder APIs, or there is indeed none 
and I am on my own and have to DIMyself?

Thanks,
OC


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

This email sent to arch...@mail-archive.com

Re: ERXSQLHelper

2015-01-12 Thread Theodore Petrosky
have you looked at the migrations? 
   
ERXMigrationTable personTable = database.existingTableNamed(person);

personTable.existingColumnNamed(Foo).renameTo(Bar”);

personTable.newStringColumn(name, width, allowsNull)



On Jan 12, 2015, at 12:51 PM, OC o...@ocs.cz wrote:

 Hello there,
 
 I need to generate add (and later also rename/drop) column SQL commands for 
 given EOAttributes, like e.g.,
 
 ALTER TABLE T_FOO ADD COLUMN C_BAR VARCHAR(256);
 
 etc. So far, I haven't succeeded to find appropriate service in ERXSQLHelper 
 (nor elsewhere): there seems to be dozen-odd methods to generate schema SQL 
 for entities, but absolutely none for attributes. Am I just blind and there 
 is an appropriate SQL generator somewhere in EOF/WOnder APIs, or there is 
 indeed none and I am on my own and have to DIMyself?
 
 Thanks,
 OC
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/tedpet5%40yahoo.com
 
 This email sent to tedp...@yahoo.com


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

This email sent to arch...@mail-archive.com