Parameterizing table name

John Abraham <[email protected]> Wed, 23 Nov 2011 15:18:12 -0700
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <CAPstF45tROD0M3h6ba8UfL4bOzWPQxjeZrZKW1kbu3VEbWJ9Dw@mail.gmail.com>
--e89a8f3b9d3bac530804b26e4be6
Content-Type: text/plain; charset=ISO-8859-1

How would you recommend parameterizing table names or column names?

For instance, I have

public static final SRecordMeta <Parcels> meta = 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 the
above line to:

public static final SRecordMeta <Parcels> meta = 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 weird
mental block on my part.  Can I just remove the final modifier and add a
static initialization routine?

--
John

--e89a8f3b9d3bac530804b26e4be6
Content-Type: text/html; charset=ISO-8859-1
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>





How would you recommend parameterizing table names or column names?<br><br>=
For instance, I have <br><span style=3D"font-family: courier new,monospace;=
"><br>public static final SRecordMeta &lt;Parcels&gt; meta =3D new SRecordM=
eta&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=
 SRecordMeta &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>




<!-- |**|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=3D2038/stime=3D1322086695" 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=
JmcmgyOG84BF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY=
wNmdHIEc2xrA3N0bmdzBHN0aW1lAzEzMjIwODY2OTU-">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=
JkcDFvbnZ1BF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY=
wNmdHIEc2xrA2hwZgRzdGltZQMxMzIyMDg2Njk1">
        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>

--e89a8f3b9d3bac530804b26e4be6--