db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Wood <jus...@braidquest.com>
Subject Getting the name(s) of primary columns
Date Sat, 15 Nov 2003 16:58:07 GMT
I would like to get the names of the primary key columns of a table.   

I tried to use the map package clases to figure out the name of the primary 
key like so

...
		MyTableMapBuilder mapBuilder = new MyTableMapBuilder();
		mapBuilder.doBuild();
		DatabaseMap map = mapBuilder.getDatabaseMap();
		ColumnMap[] colMap = map.getIdTable().getColumns();
		
		String keyColumnName=null;
		for (int i=0;i<colMap.length;i++) {
			if (colMap[i].isPrimaryKey()) {
				keyColumnName=colMap[i].getColumnName();
				break;
			}
		}
		
		System.out.println("key column name: " + keyColumnName);
...

but this returns 'ID_TABLE_ID' and the name of my primary key column is simply 
'ID'.

Is there another way? 

Justin


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


Mime
View raw message