Re: Switch erprototypes programmatically
Ramsey Gurley <[email protected]> Thu, 13 Nov 2014 09:33:32 -0700
| Newsgroups | gmane.comp.web.webobjects.wonder-disc |
|---|---|
| Message-ID | <[email protected]> |
For development, I set the h2 connection in the Properties.dev file instead=
of using code
# H2 connection URL
dbConnectURLGLOBAL=3Djdbc:h2:file://tmp/Example
# Because H2 doesn't have deferred fk constraints
com.webobjects.eoaccess.ERXEntityDependencyOrderingDelegate.active=3Dtrue
Typically, I remove the database config from the model entirely. Then you c=
an set the live connection in your app server's ~/WebObjects.properties fil=
e. If you=92re confident your version control is private, then you could pu=
t it in the app's Resources/Properties file.
I generally never need to set my prototypes. Wonder seems to figure out whi=
ch ones to use based on the db plugin being used. There are properties to s=
et the prototypes as well though, if you want to do so explicitly
http://jenkins.wocommunity.org/job/Wonder/javadoc/er/extensions/eof/ERXMode=
lGroup.html
On Nov 13, 2014, at 3:24 AM, Giancarlo Dessena <giancarlo.dessena@xyrality.=
com> wrote:
> Hello everybody,
> =
> I am trying to setup unit testing with a h2 in memory db.
> =
> Since our production database is a postgres database, I need to switch to=
the h2 erprototypes for testing .
> I do this before any EO operation is done, by using this code snippet:
> =
> =
> String dbUrl =3D "jdbc:h2:mem:test;DB_CLOSE_DELAY=3D-1";
> String dbUsername =3D "sa";
> String dbPassword =3D "";
> String dbDriverClass =3D "org.h2.Driver";
> String erprototype =3D "H2PlugIn";
> =
> NSMutableDictionary<String, Object> connectionDictionary =3D new NSMutabl=
eDictionary<String, Object>();
> connectionDictionary.put("URL", dbUrl);
> connectionDictionary.put("username", dbUsername);
> connectionDictionary.put("password", dbPassword);
> connectionDictionary.put("plugin", erprototype);
> =
> for (EOModel model : EOModelGroup.defaultGroup().models())
> {
> if (!model.name().equals("erprototypes"))
> {
> model.setConnectionDictionary(connectionDictionary);
> }
> }
> =
> This ensures that the right adapter for the model is correct, but unfortu=
nately the types of the model are not. =
> MyModel
> {password =3D =93=94; jdbc2Info =3D {NON_NULLABLE_COLUMNS =3D =93T=94; DR=
IVER_NAME =3D =93H2 JDBC Driver"; ...
> =
> For example I can see that the datatype of the intNumber prototype is sti=
ll the postgres one (int4) and not the h2 one (Integer).
> When I change the default prototype in the eomodeller to h2 everything wo=
rks perfectly.
> =
> So my question is how do I change the erprototypes programmatically?
> =
> Best regards
> =
> Carlo
> =
> -------------------------------------------------------------------------=
-----
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://pubads.g.doubleclick.net/gampad/clk?id=3D154624111&iu=3D/4140/ostg=
.clktrk_______________________________________________
> Wonder-disc mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wonder-disc
---------------------------------------------------------------------------=
---
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=3D154624111&iu=3D/4140/ostg.c=
lktrk