On Mon, May 9, 2011 at 10:12 AM, phil swenson <[email protected]> wrote: > What if your sql is "select id as id_alias from users where username ='phil'"? > > Then the code would be > > id = resultset.id_alias > > > I think you need dynamic typing for this sort of thing.
No, you need some form of dynamic typing if you want the type of ResultSet to change to include a property by the name of the column in the result set at runtime. While you couldn't get this same snippet in Java (due to the uniform access principle), there is no reason you couldn't have written a library that returned a subclass of ResultSet that did have this property. Ideally, you'd probably return another type that used a ResultSet, but the idea is simply that at runtime the requirements for the type of "resultset" are quite statically known for a well behaved program. More boilerplate? Of course. I do believe effort could be made to reduce that boilerplate some, though. (And again, I point to libraries on other strongly typed languages that solve this problem in a much more typesafe way. They can still fail at runtime, I'm not trying to claim that isn't the case.) -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
