[#2328] Pull up UpdatableTable.getKeys() and getReferencesFrom() methods

to Table
This commit is contained in:
Lukas Eder 2013-03-10 12:40:38 +01:00
parent a31007d1cb
commit b100f91d21
6 changed files with 48 additions and 54 deletions

View File

@ -46,6 +46,14 @@ DROP TABLE IF EXISTS t_877/
DROP TABLE IF EXISTS t_booleans/
DROP TABLE IF EXISTS t_identity/
DROP TABLE IF EXISTS t_identity_pk/
DROP TABLE IF EXISTS t_2327_uk_only/
CREATE TABLE t_2327_uk_only (
id INTEGER,
CONSTRAINT uk_t_2327_uk_only UNIQUE (id)
)
/
CREATE TABLE t_identity_pk (
id INTEGER AUTO_INCREMENT,

View File

@ -167,6 +167,27 @@ public interface Table<R extends Record> extends TableLike<R> {
*/
Identity<R, ? extends Number> getIdentity();
/**
* Retrieve all of the table's unique keys.
*
* @return All keys. This is never <code>null</code>. This is never empty
* for {@link UpdatableTable}s because an updatable table always has
* at least a primary key. This method returns an unmodifiable list.
*/
List<UniqueKey<R>> getKeys();
/**
* Get a list of <code>FOREIGN KEY</code>'s of a specific table, referencing
* a this table.
*
* @param <O> The other table's record type
* @param other The other table of the foreign key relationship
* @return Some other table's <code>FOREIGN KEY</code>'s towards an this
* table. This is never <code>null</code>. This method returns an
* unmodifiable list.
*/
<O extends Record> List<ForeignKey<O, R>> getReferencesFrom(Table<O> other);
/**
* Get the list of <code>FOREIGN KEY</code>'s of this table
*

View File

@ -35,8 +35,6 @@
*/
package org.jooq;
import java.util.List;
import org.jooq.conf.Settings;
/**
@ -57,27 +55,6 @@ public interface UpdatableTable<R extends Record> extends Table<R> {
*/
UniqueKey<R> getPrimaryKey();
/**
* Retrieve all of the table's unique keys.
*
* @return All keys. This is never <code>null</code> or empty, because
* {@link UpdatableTable}'s always have at least a primary key. This
* method returns an unmodifiable list.
*/
List<UniqueKey<R>> getKeys();
/**
* Get a list of <code>FOREIGN KEY</code>'s of a specific table, referencing
* a this table.
*
* @param <O> The other table's record type
* @param other The other table of the foreign key relationship
* @return Some other table's <code>FOREIGN KEY</code>'s towards an this
* table. This is never <code>null</code>. This method returns an
* unmodifiable list.
*/
<O extends Record> List<ForeignKey<O, R>> getReferencesFrom(Table<O> other);
/**
* A "version" field holding record version information used for optimistic
* locking

View File

@ -59,6 +59,7 @@ import org.jooq.TableLike;
import org.jooq.TableOnStep;
import org.jooq.TableOptionalOnStep;
import org.jooq.TablePartitionByStep;
import org.jooq.UniqueKey;
import org.jooq.tools.StringUtils;
/**
@ -162,6 +163,24 @@ abstract class AbstractTable<R extends Record> extends AbstractQueryPart impleme
return null;
}
/**
* {@inheritDoc}
* <p>
* Subclasses should override this method
*/
@Override
public List<UniqueKey<R>> getKeys() {
return Collections.emptyList();
}
/**
* {@inheritDoc}
*/
@Override
public final <O extends Record> List<ForeignKey<O, R>> getReferencesFrom(Table<O> other) {
return other.getReferencesTo(this);
}
/**
* {@inheritDoc}
* <p>

View File

@ -41,14 +41,12 @@ import static org.jooq.impl.Factory.fieldByName;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.jooq.Catalog;
import org.jooq.DataType;
import org.jooq.ForeignKey;
import org.jooq.Meta;
import org.jooq.Record;
import org.jooq.Result;
@ -317,16 +315,6 @@ class MetaImpl implements Meta {
return null;
}
@Override
public final List<UniqueKey<Record>> getKeys() {
return Collections.emptyList();
}
@Override
public final <O extends Record> List<ForeignKey<O, Record>> getReferencesFrom(Table<O> other) {
return other.getReferencesTo(this);
}
@Override
public final TableField<Record, ? extends Number> getRecordVersion() {
return null;

View File

@ -35,10 +35,6 @@
*/
package org.jooq.impl;
import java.util.Collections;
import java.util.List;
import org.jooq.ForeignKey;
import org.jooq.Record;
import org.jooq.Schema;
import org.jooq.Table;
@ -82,16 +78,6 @@ public class UpdatableTableImpl<R extends Record> extends TableImpl<R> implement
return null;
}
/**
* {@inheritDoc}
* <p>
* Subclasses should override this method
*/
@Override
public List<UniqueKey<R>> getKeys() {
return Collections.emptyList();
}
/**
* {@inheritDoc}
* <p>
@ -111,9 +97,4 @@ public class UpdatableTableImpl<R extends Record> extends TableImpl<R> implement
public TableField<R, ? extends java.util.Date> getRecordTimestamp() {
return null;
}
@Override
public final <O extends Record> List<ForeignKey<O, R>> getReferencesFrom(Table<O> other) {
return other.getReferencesTo(this);
}
}