|
|||||||||
| 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 String |
USE_UNIQUE_TABLE_NAMES
Property name which indicates unique table names should be generated. |
| Method Summary | |
|---|---|
protected Object |
clone()
Clones the vendor-specific policy for generator session. |
String |
getColumnName(String className,
String fieldName,
String tableName)
Returns the name of a column for a given field in a given class. |
String |
getConstraintColumnName(String tableName,
String columnName)
Returns the name of the column which represents a foreign key in the named table. |
String |
getConstraintName(String relName,
String uniqueId)
Returns the name of a constraint corresponding to the named relationship. |
com.sun.jdo.spi.persistence.generator.database.JDBCInfo |
getJDBCInfo(String fieldName,
String fieldType)
Returns JDBC type information corresponding to the given field name and type. |
static String |
getJdbcTypeName(int type)
Provide the String name of a JDBC type, as per java.sql.Types. |
String |
getJoinTableName(String className1,
String className2)
Returns the name of a join table which joins the tables that correspond to the two named classes. |
static MappingPolicy |
getMappingPolicy(String databaseType)
Returns a vendor-specifc MappingPolicy instance. |
static String |
getOverrideForLength(String className,
String fieldName)
Provides a String that can be recognized as a policy to override the default length of a field. |
static String |
getOverrideForNullability(String className,
String fieldName)
Provides a String that can be recognized as a policy to override the default nullability of a field. |
static String |
getOverrideForPrecision(String className,
String fieldName)
Provides a String that can be recognized as a policy to override the default precision of a field. |
static String |
getOverrideForScale(String className,
String fieldName)
Provides a String that can be recognized as a policy to override the default scale of a field. |
static String |
getOverrideForType(String className,
String fieldName)
Provides a String that can be recognized as a policy to override the default type of a field. |
String |
getPrimaryKeyConstraintName(String tableName)
Returns the name of a PK constraint, unique-ified as required. |
String |
getSQLTypeName(int jdbcType)
Returns the String name of the SQL type for a given JDBC type. |
String |
getTableName(String name,
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(Properties props)
Sets user-provided policy to that provided in the given properties. |
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 String USE_UNIQUE_TABLE_NAMES
| Method Detail |
|---|
public static MappingPolicy getMappingPolicy(String databaseType)
throws IOException
databaseType - a database vendor name as a String.
IOException - if there are problems reading the vendor-
specific mappinng policy file
protected Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException - never thrownpublic void setUserPolicy(Properties props)
props - Properties which override built in defaults.public void setUniqueTableName(boolean uniqueTableName)
uniqueTableName - If true, tables names will be
unique.public String getSQLTypeName(int jdbcType)
jdbcType - One of the values from java.sql.Types.
public com.sun.jdo.spi.persistence.generator.database.JDBCInfo getJDBCInfo(String fieldName,
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 String getOverrideForLength(String className,
String fieldName)
className - name of a classfieldName - name of a field in that class
public static String getOverrideForNullability(String className,
String fieldName)
className - name of a classfieldName - name of a field in that class
public static String getOverrideForPrecision(String className,
String fieldName)
className - name of a classfieldName - name of a field in that class
public static String getOverrideForScale(String className,
String fieldName)
className - name of a classfieldName - name of a field in that class
public static String getOverrideForType(String className,
String fieldName)
className - name of a classfieldName - name of a field in that class
public static String getJdbcTypeName(int type)
throws IllegalArgumentException
type - A value from java.sql.Types
type
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 String getTableName(String name,
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 String getColumnName(String className,
String fieldName,
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 String getConstraintColumnName(String tableName,
String columnName)
tableName - Name of the table in which the FK column will be
created.columnName - Name of PK column in referenced table.
public String getConstraintName(String relName,
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 String getPrimaryKeyConstraintName(String tableName)
tableName - Name of a table on which a constraint is to be placed.
public String getJoinTableName(String className1,
String className2)
className1 - Name of one class to join.className2 - Name of the other class to join.
public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||