|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.jdo.spi.persistence.generator.database.MappingPolicy
public class MappingPolicy
Describes how Java classes and their fields are to be mapped to database tables and columns
| Field Summary | |
|---|---|
static java.lang.String |
USE_UNIQUE_TABLE_NAMES
Property name which indicates unique table names should be generated. |
| Method Summary | |
|---|---|
protected java.lang.Object |
clone()
Clones the vendor-specific policy for generator session. |
java.lang.String |
getColumnName(java.lang.String className,
java.lang.String fieldName,
java.lang.String tableName)
Returns the name of a column for a given field in a given class. |
java.lang.String |
getConstraintColumnName(java.lang.String tableName,
java.lang.String columnName)
Returns the name of the column which represents a foreign key in the named table. |
java.lang.String |
getConstraintName(java.lang.String relName,
java.lang.String uniqueId)
Returns the name of a constraint corresponding to the named relationship. |
com.sun.jdo.spi.persistence.generator.database.JDBCInfo |
getJDBCInfo(java.lang.String fieldName,
java.lang.String fieldType)
Returns JDBC type information corresponding to the given field name and type. |
static java.lang.String |
getJdbcTypeName(int type)
Provide the String name of a JDBC type, as per java.sql.Types. |
java.lang.String |
getJoinTableName(java.lang.String className1,
java.lang.String className2)
Returns the name of a join table which joins the tables that correspond to the two named classes. |
static MappingPolicy |
getMappingPolicy(java.lang.String databaseType)
Returns a vendor-specifc MappingPolicy instance. |
static java.lang.String |
getOverrideForLength(java.lang.String className,
java.lang.String fieldName)
Provides a String that can be recognized as a policy to override the default length of a field. |
static java.lang.String |
getOverrideForNullability(java.lang.String className,
java.lang.String fieldName)
Provides a String that can be recognized as a policy to override the default nullability of a field. |
static java.lang.String |
getOverrideForPrecision(java.lang.String className,
java.lang.String fieldName)
Provides a String that can be recognized as a policy to override the default precision of a field. |
static java.lang.String |
getOverrideForScale(java.lang.String className,
java.lang.String fieldName)
Provides a String that can be recognized as a policy to override the default scale of a field. |
static java.lang.String |
getOverrideForType(java.lang.String className,
java.lang.String fieldName)
Provides a String that can be recognized as a policy to override the default type of a field. |
java.lang.String |
getPrimaryKeyConstraintName(java.lang.String tableName)
Returns the name of a PK constraint, unique-ified as required. |
java.lang.String |
getSQLTypeName(int jdbcType)
Returns the String name of the SQL type for a given JDBC type. |
java.lang.String |
getTableName(java.lang.String name,
java.lang.String uniqueName)
Returns the name of a table for a given class, as per current policy. |
void |
setUniqueTableName(boolean uniqueTableName)
Sets whether or not unique table names should be generated. |
void |
setUserPolicy(java.util.Properties props)
Sets user-provided policy to that provided in the given properties. |
java.lang.String |
toString()
Debug support. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String USE_UNIQUE_TABLE_NAMES
| Method Detail |
|---|
public static MappingPolicy getMappingPolicy(java.lang.String databaseType)
throws java.io.IOException
databaseType - a database vendor name as a String.
java.io.IOException - if there are problems reading the vendor-
specific mappinng policy file
protected java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - never thrownpublic void setUserPolicy(java.util.Properties props)
props - Properties which override built in defaults.public void setUniqueTableName(boolean uniqueTableName)
uniqueTableName - If true, tables names will be
unique.public java.lang.String getSQLTypeName(int jdbcType)
jdbcType - One of the values from java.sql.Types.
public com.sun.jdo.spi.persistence.generator.database.JDBCInfo getJDBCInfo(java.lang.String fieldName,
java.lang.String fieldType)
null or there is no
fieldName - specific information already existing, the default for the
given fieldType is returned. Otherwise, information specific to the
fieldName is returned. Note: It is possible to have a field
in a class have the same name as another class; this mechanism is not
robust in that case:
class Foo { }
class MyFoo {
Foo Foo = new Foo();
}
We think this obfuscation unlikely to occur.
fieldName - Name of field for which information is needed. May
be null, in which case only fieldType is used to determine returned
information.fieldType - Name of a Java type.
public static java.lang.String getOverrideForLength(java.lang.String className,
java.lang.String fieldName)
className - name of a classfieldName - name of a field in that class
public static java.lang.String getOverrideForNullability(java.lang.String className,
java.lang.String fieldName)
className - name of a classfieldName - name of a field in that class
public static java.lang.String getOverrideForPrecision(java.lang.String className,
java.lang.String fieldName)
className - name of a classfieldName - name of a field in that class
public static java.lang.String getOverrideForScale(java.lang.String className,
java.lang.String fieldName)
className - name of a classfieldName - name of a field in that class
public static java.lang.String getOverrideForType(java.lang.String className,
java.lang.String fieldName)
className - name of a classfieldName - name of a field in that class
public static java.lang.String getJdbcTypeName(int type)
throws java.lang.IllegalArgumentException
type - A value from java.sql.Types
type
java.lang.IllegalArgumentException - if type is not recognized
as being a valid member of java.sql.Types. Note that only a subset of
the types in java.sql.Types are recognized.
public java.lang.String getTableName(java.lang.String name,
java.lang.String uniqueName)
name - Basis for what the returned table should be named, for
example the unqualified name of a class.uniqueName - Used if the current policy is to return a unique
name. Client must provide a name that is unique to them.
DatabaseGenerator.generate(com.sun.jdo.api.persistence.model.Model, java.util.List, com.sun.jdo.spi.persistence.generator.database.MappingPolicy, java.lang.String, java.lang.String, boolean).
public java.lang.String getColumnName(java.lang.String className,
java.lang.String fieldName,
java.lang.String tableName)
className - Name of the class containing the field.fieldName - Name of the field for which a column name is returned.tableName - Name of the table in which the column name is created.
public java.lang.String getConstraintColumnName(java.lang.String tableName,
java.lang.String columnName)
tableName - Name of the table in which the FK column will be
created.columnName - Name of PK column in referenced table.
public java.lang.String getConstraintName(java.lang.String relName,
java.lang.String uniqueId)
relName - Name of a relationship.uniqueId - Id that can be appened to relName to distinguish it
from other relNames in the database. Will be appended only if
uniqueTableName is true.
public java.lang.String getPrimaryKeyConstraintName(java.lang.String tableName)
tableName - Name of a table on which a constraint is to be placed.
public java.lang.String getJoinTableName(java.lang.String className1,
java.lang.String className2)
className1 - Name of one class to join.className2 - Name of the other class to join.
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||