Switch erprototypes programmatically
Giancarlo Dessena <[email protected]> Thu, 13 Nov 2014 11:24:01 +0100
| Newsgroups | gmane.comp.web.webobjects.wonder-disc |
|---|---|
| Message-ID | <[email protected]> |
--===============3752521280052597286==
Content-Type: multipart/alternative;
boundary="Apple-Mail=_F646F295-02A2-443F-A972-6A4AF41DAC0D"
--Apple-Mail=_F646F295-02A2-443F-A972-6A4AF41DAC0D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=windows-1252
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 =
NSMutableDictionary<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 =
unfortunately the types of the model are not.=20
MyModel
{password =3D =93=94; jdbc2Info =3D {NON_NULLABLE_COLUMNS =3D =93T=94; =
DRIVER_NAME =3D =93H2 JDBC Driver"; ...
For example I can see that the datatype of the intNumber prototype is =
still the postgres one (int4) and not the h2 one (Integer).
When I change the default prototype in the eomodeller to h2 everything =
works perfectly.
So my question is how do I change the erprototypes programmatically?
Best regards
Carlo
--Apple-Mail=_F646F295-02A2-443F-A972-6A4AF41DAC0D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=windows-1252
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello =
everybody,<div><br></div><div>I am trying to setup unit testing with a =
h2 in memory db.</div><div><br></div><div>Since our production database =
is a postgres database, I need to switch to the h2 erprototypes for =
testing .</div><div>I do this before any EO operation is done, by using =
this code snippet:</div><div><br></div><div><br></div><div><div =
style=3D"margin: 0px; font-size: 11px; font-family: Monaco; color: =
rgb(57, 51, 255);"><span style=3D"color: #000000">String<span =
class=3D"Apple-tab-span" style=3D"white-space:pre"> =
</span></span><span style=3D"color: #0326cc">dbUrl</span><span =
style=3D"color: #000000"><span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span>=3D =
</span>"jdbc:h2:mem:test;DB_CLOSE_DELAY=3D-1"<span style=3D"color: =
#000000">;</span></div><div style=3D"margin: 0px; font-size: 11px; =
font-family: Monaco;">String<span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span><span style=3D"color: =
#0326cc">dbUsername</span><span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span>=3D <span style=3D"color: =
#3933ff">"sa"</span>;</div><div style=3D"margin: 0px;"><span =
style=3D"font-family: Monaco; font-size: 11px;">String</span><span =
class=3D"Apple-tab-span" style=3D"font-family: Monaco; font-size: 11px; =
white-space: pre;"> </span><span style=3D"font-family: Monaco; =
font-size: 11px; color: rgb(3, 38, 204);">dbPassword</span><span =
class=3D"Apple-tab-span" style=3D"font-family: Monaco; font-size: 11px; =
white-space: pre;"> </span><font face=3D"Monaco"><span =
style=3D"font-size: 11px;">=3D </span></font><span style=3D"color: =
rgb(57, 51, 255); font-family: Monaco; font-size: 11px;">"</span><font =
color=3D"#3933ff" face=3D"Monaco"><span style=3D"font-size: =
11px;">"</span></font><font face=3D"Monaco"><span style=3D"font-size: =
11px;">;</span></font></div><div style=3D"margin: 0px; font-size: 11px; =
font-family: Monaco;">String<span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span><span style=3D"color: =
#0326cc">dbDriverClass</span><span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span>=3D <span style=3D"color: =
#3933ff">"org.h2.Driver"</span>;</div><div style=3D"margin: 0px;"><font =
face=3D"Monaco"><span style=3D"font-size: =
11px;">String</span></font><span class=3D"Apple-tab-span" =
style=3D"font-family: Monaco; font-size: 11px; white-space: pre;"> =
</span><span style=3D"font-family: Monaco; font-size: 11px; color: =
rgb(3, 38, 204);">erprototype</span><span class=3D"Apple-tab-span" =
style=3D"font-family: Monaco; font-size: 11px; white-space: pre;"> =
</span><font face=3D"Monaco"><span style=3D"font-size: =
11px;">=3D </span></font><span style=3D"color: rgb(57, 51, 255); =
font-family: Monaco; font-size: 11px;">"</span><font color=3D"#3933ff" =
face=3D"Monaco"><span style=3D"font-size: =
11px;">H2PlugIn"</span></font><font face=3D"Monaco"><span =
style=3D"font-size: 11px;">;</span></font></div></div><div =
style=3D"margin: 0px; font-size: 11px; font-family: =
Monaco;"><br></div><div style=3D"margin: 0px;"><div style=3D"font-family: =
Monaco; font-size: 11px; margin: 0px;">NSMutableDictionary<String, =
Object> <span style=3D"color: #7e504f">connectionDictionary</span> =3D =
<span style=3D"color: #931a68">new</span> NSMutableDictionary<String, =
Object>();</div><div style=3D"font-family: Monaco; font-size: 11px; =
margin: 0px; color: rgb(126, 80, 79);">connectionDictionary<span =
style=3D"color: #000000">.put(</span><span style=3D"color: =
#3933ff">"URL"</span><span style=3D"color: #000000">, </span><span =
style=3D"color: #0326cc">dbUrl</span><span style=3D"color: =
#000000">);</span></div><div style=3D"font-family: Monaco; font-size: =
11px; margin: 0px; color: rgb(126, 80, 79);">connectionDictionary<span =
style=3D"color: #000000">.put(</span><span style=3D"color: =
#3933ff">"username"</span><span style=3D"color: #000000">, </span><span =
style=3D"color: #0326cc">dbUsername</span><span style=3D"color: =
#000000">);</span></div><div style=3D"font-family: Monaco; font-size: =
11px; margin: 0px; color: rgb(126, 80, 79);">connectionDictionary<span =
style=3D"color: #000000">.put(</span><span style=3D"color: =
#3933ff">"password"</span><span style=3D"color: #000000">, </span><span =
style=3D"color: #0326cc">dbPassword</span><span style=3D"color: =
#000000">);</span></div><div style=3D"font-family: Monaco; font-size: =
11px; margin: 0px; color: rgb(126, 80, 79);">connectionDictionary<span =
style=3D"color: #000000">.put(</span><span style=3D"color: =
#3933ff">"plugin"</span><span style=3D"color: #000000">, </span><span =
style=3D"color: #0326cc">erprototype</span><span style=3D"color: =
#000000">);</span></div><div style=3D"font-family: Monaco; font-size: =
11px; margin: 0px; min-height: 15px;"><br></div><div style=3D"font-family:=
Monaco; font-size: 11px; margin: 0px;"><span style=3D"color: =
#931a68">for</span> (EOModel <span style=3D"color: #7e504f">model</span> =
: EOModelGroup.defaultGroup().models())</div><div style=3D"font-family: =
Monaco; font-size: 11px; margin: 0px;">{</div><div style=3D"font-family: =
Monaco; font-size: 11px; margin: 0px;"><span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span><span style=3D"color: =
#931a68">if</span> (!<span style=3D"color: =
#7e504f">model</span>.name().equals(<span style=3D"color: =
#3933ff">"erprototypes"</span>))</div><div style=3D"font-family: Monaco; =
font-size: 11px; margin: 0px;"><span class=3D"Apple-tab-span" =
style=3D"white-space: pre;"> </span>{</div><div style=3D"font-family: =
Monaco; font-size: 11px; margin: 0px;"><span class=3D"Apple-tab-span" =
style=3D"white-space: pre;"> </span><span class=3D"Apple-tab-span" =
style=3D"white-space: pre;"> </span><span style=3D"color: rgb(126, =
80, 79);">model</span>.setConnectionDictionary(<span style=3D"color: =
rgb(126, 80, 79);">connectionDictionary</span>);</div><div =
style=3D"font-family: Monaco; font-size: 11px; margin: 0px;"><span =
class=3D"Apple-tab-span" style=3D"white-space: pre;"> =
</span>}</div><div style=3D"font-family: Monaco; font-size: 11px; =
margin: 0px;">}</div><div style=3D"font-family: Monaco; font-size: 11px; =
margin: 0px;"><br></div><div style=3D"margin: 0px;">This ensures that =
the right adapter for the model is correct, but unfortunately the types =
of the model are not. </div><div style=3D"margin: 0px;"><div =
style=3D"margin: 0px; font-size: 11px; font-family: =
Monaco;">MyModel</div><div style=3D"margin: 0px; font-size: 11px; =
font-family: Monaco;">{password =3D =93=94; jdbc2Info =3D =
{NON_NULLABLE_COLUMNS =3D =93T=94; DRIVER_NAME =3D =93H2 JDBC Driver"; =
...</div></div><div style=3D"margin: 0px;"><br></div><div style=3D"margin:=
0px;">For example I can see that the datatype of the intNumber =
prototype is still the postgres one (int4) and not the h2 one =
(Integer).</div><div style=3D"margin: 0px;">When I change the default =
prototype in the eomodeller to h2 everything works perfectly.</div><div =
style=3D"margin: 0px;"><br></div><div style=3D"margin: 0px;">So my =
question is how do I change the erprototypes programmatically?</div><div =
style=3D"margin: 0px;"><br></div><div style=3D"margin: 0px;">Best =
regards</div><div style=3D"margin: 0px;"><br></div><div style=3D"margin: =
0px;">Carlo</div><div style=3D"margin: =
0px;"><br></div></div></body></html>=
--Apple-Mail=_F646F295-02A2-443F-A972-6A4AF41DAC0D--
--===============3752521280052597286==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
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=154624111&iu=/4140/ostg.clktrk
--===============3752521280052597286==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Wonder-disc mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wonder-disc
--===============3752521280052597286==--