Re: Support for ResultSetMetaData.getTableName

From: David Goodenough <david(dot)goodenough(at)btconnect(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Support for ResultSetMetaData.getTableName
Date: 2007-08-27 09:04:48
Message-ID: 200708271004.49945.david.goodenough@btconnect.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Monday 27 August 2007, Kris Jurka wrote:
> On Mon, 27 Aug 2007, Tom Lane wrote:
> > I suggest that the following mapping might be more sensible:
> >
> > getColumnName returns "a"
> > getTableName returns "c"
> > getSchemaName returns name of c's schema
> > getColumnLabel returns "b"
> >
> > where the first three fail if the SELECT column isn't a simple column
> > reference, but getColumnLabel always works.
>
> I tried that back here:
>
> http://archives.postgresql.org/pgsql-jdbc/2004-07/threads.php#00314
>
> and continuing here:
>
> http://archives.postgresql.org/pgsql-jdbc/2004-08/threads.php#00008
>
> This message demonstrates that many other drivers do Column Name/Label in
> a different way:
>
> http://archives.postgresql.org/pgsql-jdbc/2004-08/msg00012.php
>
> So while I agree with you that the above suggestions make sense from a
> blank slate, we can't do this without causing problems. It seems people
> would like us to fallback from our position of table and schema returning
> aliases, which while inconsistent, is certainly more useful at this point
> in time.
>
> Kris Jurka

I have to admit that the thought of returning an alias name for a table
had not occurred to me, what I need is the c.

My need for it is using something like sql2java, when I have a constructed
bean for each record. When I do a select that picks values from multiple
tables I would like to populate the beans with the relevant values from the
resultset. I would like this to be generic code rather than having to tell
each bean which fields to pick. For this purpose encoding the table from
which the bean comes in the bean (or its corresponding manager class) is easy,
the alias an an artifact of the select.

David

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Pawel Cesar Sanjuan Szklarz 2007-08-27 10:38:27 Re: jdbc problem
Previous Message Marek Lewczuk 2007-08-27 07:35:54 small correction to AbstractJdbc2Array