Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 02 Aug 2012 18:28:12 -0500 Date: Fri, 03 Aug 2012 02:27:47 +0300 From: Donkey Hottie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Type of a generic class? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: Lines: 83 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-lGsbcSz8wjeWRxPA72n+WGuQIWgevQPmybeiNE3jWY4sP6nc6guLpUhzMmSB2z9Cz3D94B1XB2eo2Ag!N21p1fVb0OVNa+sJesXEJeqeX3yZVZn2b2jSmLokxOzHN5f36jgLELjWsaBYOhFTi72DS5w= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4365 Xref: csiph.com comp.lang.java.programmer:17012 03.08.2012 00:08, markspace kirjoitti: > On 8/2/2012 12:04 PM, Donkey Hottie wrote: > >> First problem I have is to translate the type to a lower level >> application API call. I can not leave the cast or type conversion to >> compiler only. > > > I'm going to ignore other obvious problems and simply focus on the big > picture here. You idea how to accomplish this looks *TERRIBLE*. Why > aren't you using some kind of ORM? At least use a light-weight library > for translating data base entities into objects. > I am not trying to translate database tables to objects. I have an ORM for that. I am trying to convert a simple { String name, String value } pair in database to a Global(name) so that it will convert the Java simple datatypes to a string and back. This is for system parameters, configuration parameters. It is indeed kind of spooky and strange idea, after all what is so wrong about simple String value = SystemProperties.getString("ParamName") ; It is OK, but I'm kind of toying with idea of strong typing of System Parameters: A Date can not be stored as Long or Double etc.. The back end of the system parameters is simply CREATE TABLE SystemParameters ( name varchar(64) not null primary_key, value varchar(512) ) ; That's it. That is have the table is given to me. But I want to make the Java code bit more pedantic on the types of the parameters it uses and maintains. This idea just occurred to me when I stubled against MUMPS language when learning InterSystems Ensemble. It is based on their Caché NoSQL/SQL hybrid database, and while being an ancient language, MUMPS/M has lots of interesting features, including threading and database persistence in the old Programming Language Core! I just thought I might as well copy their Global variable idea and include it in my toolbox of Java commons. It is not an ORM. I do not know about dbutils, but JPA I am very familiar with. It maps Java Objects to Relational Database records. There one attribute can have just one type. I want many types to my value attribute, but only for Java code. Just to force the apps to store at least correct type of values for properties, so that compiler stops my fellow programmer if he is about to generate a runtime error later somewhere, for example if he is trying to store 'NOW' for a value that is needed as Date. Not a big deal, but this is my idea here. > > > Also JPA will do some kinds of automatic instantiation for you: > > > > > I didn't check to see if those are the most recent docs (I don't use > this sort of feature). Google for "JPA table inheritance" and check > through the results carefully. > > >> Class is a simple version containg only the important parts. > > > Honestly, while we all appreciate the attempt, you example is far from > complete. We can guess at a few things, but you should think much more > carefully at what the real problem is and design something to illustrate > it. > > >