Re: Parameterizing table name

anthony berglas <[email protected]> Thu, 24 Nov 2011 10:14:02 +1000
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <CA+_PZMcj-mJudWyanmwdMFamnqJgP6LwUJgRd_7Qkh6TJvArEg@mail.gmail.com>
--20cf307f32b256808a04b26fece1
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Hello John,

The "final" is only a matter of style and you could certainly remove it.
 Indeed, all SimpleOrm cares about is the fact that there is a correctly
set up SRecordMeta instance -- you do not actually need any variables at
all.

That said, I would suggest you think about the order of the static
initializations.  What is causing the class to load before the ResourceUtil
one?  Solving that could be neater.

Regards,

Anthony

On Thu, Nov 24, 2011 at 8:18 AM, John Abraham <[email protected]> wrote:

> **
>
>
> How would you recommend parameterizing table names or column names?
>
> For instance, I have
>
> public static final SRecordMeta <Parcels> meta =3D new
> SRecordMeta<Parcels>(Parcels.class, "parcels");
>
> to bind my Parcels class in Java to the "parcles" table in the database.
>
> Now my clients want to switch back and forth between two different tables
> without changing the source code and recompiling, so I'd like to change t=
he
> above line to:
>
> public static final SRecordMeta <Parcels> meta =3D new
> SRecordMeta<Parcels>(Parcels.class, ResourceUtil.getProperty(rbSD,
> "sd.ParcelTableName", "parcels"));
>
> The problem is that the meta object is a public static final, so it's
> initializer is called before the resource bundle (rbSD) is read into
> memory.  And SRecordMeta.tableName is a private object with no set method=
.
>
> I've asked this before, and the answer was "it's easy to do in SimpleORM"
> but I haven't figured out that easy way to do it.  Probably just some wei=
rd
> mental block on my part.  Can I just remove the final modifier and add a
> static initialization routine?
>
> --
> John
>=20=20
>



--=20

Dr Anthony Berglas, [email protected]       Mobile: +61 4 4838 8874
Just because it is possible to push twigs along the ground with ones nose
does not necessarily mean that that is the best way to collect firewood.

--20cf307f32b256808a04b26fece1
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable





<head>

<style type=3D"text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title=20
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none;=20
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<html>
<head>
<style type=3D"text/css">
<!--
#ygrp-mkp {
  border: 1px solid #d8d8d8;
  font-family: Arial;
  margin: 10px 0;
  padding: 0 10px;
}

#ygrp-mkp hr {
  border: 1px solid #d8d8d8;
}

#ygrp-mkp #hd {
  color: #628c2a;
  font-size: 85%;
  font-weight: 700;
  line-height: 122%;
  margin: 10px 0;
}

#ygrp-mkp #ads {
  margin-bottom: 10px;
}

#ygrp-mkp .ad {
  padding: 0 0;
}

#ygrp-mkp .ad p {
  margin: 0;
}

#ygrp-mkp .ad a {
  color: #0000ff;
  text-decoration: none;
}
-->
</style>
</head>
<body>





Hello John,<div><br></div><div>The &quot;final&quot; is only a matter of st=
yle and you could certainly remove it. =A0Indeed, all SimpleOrm cares about=
 is the fact that there is a correctly set up SRecordMeta instance -- you d=
o not actually need any variables at all.</div>

<div><br></div><div>That said, I would suggest you think about the order of=
 the static initializations. =A0What is causing the class to load before th=
e ResourceUtil one? =A0Solving that could be neater.</div><div><br></div><d=
iv>

Regards,</div><div><br></div><div>Anthony<br><br><div class=3D"gmail_quote"=
>On Thu, Nov 24, 2011 at 8:18 AM, John Abraham <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:[email protected]">[email protected]</a>&gt;</span> wrote:<br><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex;">




<u></u>










<div style=3D"background-color:#fff">
<span>=A0</span>


<div>
  <div>


    <div>
=20=20=20=20=20=20
=20=20=20=20=20=20
      <p>How would you recommend parameterizing table names or column names=
?<br><br>For instance, I have <br><span style=3D"font-family:courier new,mo=
nospace"><br>public static final SRecordMeta &lt;Parcels&gt; meta =3D new S=
RecordMeta&lt;Parcels&gt;(Parcels.class, &quot;parcels&quot;);</span><br>


<br>to bind my Parcels class in Java to the &quot;parcles&quot; table in th=
e database.<br><br>Now my clients want to switch back and forth between two=
 different tables without changing the source code and recompiling, so I&#3=
9;d like to change the above line to:<br>


<br><span style=3D"font-family:courier new,monospace">public static final S=
RecordMeta &lt;Parcels&gt; meta =3D new=20
SRecordMeta&lt;Parcels&gt;(Parcels.class, ResourceUtil.getProperty(rbSD,
 &quot;sd.ParcelTableName&quot;, &quot;parcels&quot;));</span><br><br>The p=
roblem is that the meta object is a public static final, so it&#39;s initia=
lizer is called before the resource bundle (rbSD) is read into memory.=A0 A=
nd SRecordMeta.tableName is a private object with no set method.<br>


<br>I&#39;ve asked this before, and the answer was &quot;it&#39;s easy to d=
o in SimpleORM&quot; but I haven&#39;t figured out that easy way to do it.=
=A0 Probably just some weird mental block on my part.=A0 Can I just remove =
the final modifier and add a static initialization routine?<br>


<br>--<br>John <br>
</p>

    </div>
=20=20=20=20=20

=20=20=20=20
    <div style=3D"color:#fff;min-height:0"></div>


</div>



=20=20






</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><p>
</p><p>Dr Anthony Berglas, <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a>=A0=A0=A0=A0=A0=A0 Mobile: +61 4 4838 8874<=
br>
Just because it is possible to push twigs along the ground with ones nose<b=
r>
does not necessarily mean that that is the best way to collect firewood.</p=
><br>
</div>




<!-- |**|begin egp html banner|**| -->

<br>

=20=20=20=20
=20=20=20=20
<br>

<!-- |**|end egp html banner|**| -->


<div width=3D"1" style=3D"color: white; clear: both;"/>__._,_.___</div>

<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src=3D"http://geo.yahoo.com/serv?s=3D97476590/grpId=3D7360226/grpspI=
d=3D1705006905/msgId=3D2039/stime=3D1322093684" width=3D"1" height=3D"1"> <=
br>

<!-- |**|end egp html banner|**| -->

=20=20
<!-- |**|begin egp html banner|**| -->

<br>
      <div style=3D"font-family: verdana; font-size: 77%; border-top: 1px s=
olid #666; padding: 5px 0;" >
      Your email settings: Individual Email|Traditional <br>
      <a href=3D"http://groups.yahoo.com/group/SimpleORM/join;_ylc=3DX3oDMT=
JmcmxpcGc4BF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY=
wNmdHIEc2xrA3N0bmdzBHN0aW1lAzEzMjIwOTM2ODQ-">Change settings via the Web</a=
> (Yahoo! ID required) <br>
      Change settings via email: <a href=3D"mailto:SimpleORM-digest@yahoogr=
oups.com?subject=3DEmail Delivery: Digest">Switch delivery to Daily Digest<=
/a> | <a href =3D "mailto:[email protected]?subject=3D=
Change Delivery Format: Fully Featured">Switch to Fully Featured</a> <br>
           <a href=3D"http://groups.yahoo.com/group/SimpleORM;_ylc=3DX3oDMT=
JkYXEyazFkBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY=
wNmdHIEc2xrA2hwZgRzdGltZQMxMzIyMDkzNjg0">
        Visit Your Group=20
      </a> |
      <a href=3D"http://docs.yahoo.com/info/terms/">
        Yahoo! Groups Terms of Use
      </a> |
      <a href=3D"mailto:[email protected]?subject=3DUns=
ubscribe">
       Unsubscribe=20
      </a>=20
 <br>
    </div>
  <br>

<!-- |**|end egp html banner|**| -->


<div style=3D"color: white; clear: both;"/>__,_._,___</div>
</body>

</html>

--20cf307f32b256808a04b26fece1--