You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by tu...@eigentechnology.com on 2003/04/08 05:15:19 UTC

number of columns in a table

Hi,

How could I get the number of columns in a table?

getSize() ?? 

Also, would appreciate if anyone could point me to a site/turtorial/reply that
has a list of functions for me to obtain row / column / position in a row/column
etc...

best wishes
michael


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: dynamically assess the number of columns in a table

Posted by tu...@eigentechnology.com.
thanks I will give it a go.

michael



Quoting Akmal Sarhan <as...@byteaction.de>:

> here is a  method I coded to do nearly what you want, it uses reflection
> though,but have not tested it :
> 
> 
>     /**
>          * gets the db columns' names
>          *
>          * @param table the full qualified persistent class name that
> represents
>          * the table in the db
>          *
>          * @return a list of the columns
>          */
>     public List getColumns(String table)
>     {
>         Class cl = null;
>         List  columns = new ArrayList();
> 
>         try
>         {
>             String soleTable = table.substring(table.lastIndexOf('.') + 1,
> table.length());
> 
>             Log.debug(soleTable);
> 
>             String qualify = table.substring(0, table.lastIndexOf('.') + 1);
> 
>             Log.debug(qualify);
> 
>             Class       k = Class.forName(qualify + "Base" + soleTable +
> "Peer");
> 
>             Method      m = k.getMethod("getMapBuilder", new Class[] {  });
>             ColumnMap[] cmap = (ColumnMap[]) ((MapBuilder) m.invoke(null,
> new Object[]
>                 {
> 
>                 })).getDatabaseMap().getTable(soleTable.toUpperCase()).getCo
> lumns();
> 
>             for (int i = 0; i < cmap.length; i++)
>             {
>                 columns.add(cmap[i].getColumnName());
>             }
>         }
>         catch (Exception e)
>         {
>             e.printStackTrace();
>         }
> 
>         return columns;
>     }
> 
> tell me if it works for you
> regards
> Akmal
> ----- Original Message -----
> From: <tu...@eigentechnology.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Cc: <to...@db.apache.org>
> Sent: Wednesday, April 09, 2003 5:39 AM
> Subject: dynamically assess the number of columns in a table
> 
> 
> > Sorry if I have not been clear in my last post.
> >
> > Would appreciate if someone could tell me how to get access to the number
> of
> > columns in a table dynamically.
> >
> > best wishes
> > michael
> >
> >
> > Quoting turbine@eigentechnology.com:
> >
> > > Hi,
> > >
> > > How could I get the number of columns in a table?
> > >
> > > getSize() ??
> > >
> > > Also, would appreciate if anyone could point me to a
> site/turtorial/reply
> > > that
> > > has a list of functions for me to obtain row / column / position in a
> > > row/column
> > > etc...
> > >
> > > best wishes
> > > michael
> > >
> > >
> > > -------------------------------------------------
> > > This mail sent through IMP: http://horde.org/imp/
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> > >
> >
> >
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


cannot resolve getBigInteger during Compilation

Posted by tu...@eigentechnology.com.
I received a compilation error when trying to retreive a ID_REF number:

Porder porder;
int SOME_ID = porder.getSomeRef().getBigInteger();

this one worked before, but this time it gives me a Cannot resolve symbol
getBigInteger() ... ??

any import statement I should include to make it work?

michael


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: dynamically assess the number of columns in a table

Posted by Akmal Sarhan <as...@byteaction.de>.
here is a  method I coded to do nearly what you want, it uses reflection
though,but have not tested it :


    /**
         * gets the db columns' names
         *
         * @param table the full qualified persistent class name that
represents
         * the table in the db
         *
         * @return a list of the columns
         */
    public List getColumns(String table)
    {
        Class cl = null;
        List  columns = new ArrayList();

        try
        {
            String soleTable = table.substring(table.lastIndexOf('.') + 1,
table.length());

            Log.debug(soleTable);

            String qualify = table.substring(0, table.lastIndexOf('.') + 1);

            Log.debug(qualify);

            Class       k = Class.forName(qualify + "Base" + soleTable +
"Peer");

            Method      m = k.getMethod("getMapBuilder", new Class[] {  });
            ColumnMap[] cmap = (ColumnMap[]) ((MapBuilder) m.invoke(null,
new Object[]
                {

                })).getDatabaseMap().getTable(soleTable.toUpperCase()).getCo
lumns();

            for (int i = 0; i < cmap.length; i++)
            {
                columns.add(cmap[i].getColumnName());
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        return columns;
    }

tell me if it works for you
regards
Akmal
----- Original Message -----
From: <tu...@eigentechnology.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Cc: <to...@db.apache.org>
Sent: Wednesday, April 09, 2003 5:39 AM
Subject: dynamically assess the number of columns in a table


> Sorry if I have not been clear in my last post.
>
> Would appreciate if someone could tell me how to get access to the number
of
> columns in a table dynamically.
>
> best wishes
> michael
>
>
> Quoting turbine@eigentechnology.com:
>
> > Hi,
> >
> > How could I get the number of columns in a table?
> >
> > getSize() ??
> >
> > Also, would appreciate if anyone could point me to a
site/turtorial/reply
> > that
> > has a list of functions for me to obtain row / column / position in a
> > row/column
> > etc...
> >
> > best wishes
> > michael
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
>
>
>
>
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: dynamically assess the number of columns in a table

Posted by Chris K Chew <ch...@fenetics.com>.
> From: turbine@eigentechnology.com
>
> Would appreciate if someone could tell me how to get access to
> the number of
> columns in a table dynamically.

Try browsing the Torque javadocs.  I have never done this, but it looks like
you could do something like:

int numColumns =
Torque.getDatabaseMap.getTable("TABLE_NAME").getColumns().length;

Good luck,

Chris


dynamically assess the number of columns in a table

Posted by tu...@eigentechnology.com.
Sorry if I have not been clear in my last post.

Would appreciate if someone could tell me how to get access to the number of
columns in a table dynamically.

best wishes
michael


Quoting turbine@eigentechnology.com:

> Hi,
> 
> How could I get the number of columns in a table?
> 
> getSize() ?? 
> 
> Also, would appreciate if anyone could point me to a site/turtorial/reply
> that
> has a list of functions for me to obtain row / column / position in a
> row/column
> etc...
> 
> best wishes
> michael
> 
> 
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

dynamically assess the number of columns in a table

Posted by tu...@eigentechnology.com.
Sorry if I have not been clear in my last post.

Would appreciate if someone could tell me how to get access to the number of
columns in a table dynamically.

best wishes
michael


Quoting turbine@eigentechnology.com:

> Hi,
> 
> How could I get the number of columns in a table?
> 
> getSize() ?? 
> 
> Also, would appreciate if anyone could point me to a site/turtorial/reply
> that
> has a list of functions for me to obtain row / column / position in a
> row/column
> etc...
> 
> best wishes
> michael
> 
> 
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org