org.hibernatespatial.pojo
Class AutoMapper

java.lang.Object
  extended by org.hibernatespatial.pojo.AutoMapper

public class AutoMapper
extends Object

Author:
Karel Maesen, Geovise BVBA

Field Summary
protected static org.slf4j.Logger logger
           
protected static String PACKAGE_NAME
           
 
Constructor Summary
AutoMapper()
           
 
Method Summary
static String getAttributeGetterName(String catalog, String schema, String tableName, String attribute)
          Returns the name of the getter-method for the attribute
static List<String> getAttributes(String catalog, String schema, String tableName)
          Returns the attribute names of the class to with the specified table is mapped
static String getAttributeSetterName(String catalog, String schema, String tableName, String attribute)
          Returns the name of the setter-method for the attribute
static Class<?> getClass(String catalog, String schema, String tableName)
          Returns the Class object to which the specified table is mapped
static String getGeometryAttribute(String catalog, String schema, String tableName)
          Returns the (default) Geometry-valued attribute
static String getIdAttribute(String catalog, String schema, String tableName)
          Returns the Identifier attribute
static List<String[]> getMappedTables()
          Returns the tables mapped by this automapper.
static org.dom4j.Document map(Connection conn, String catalog, String schema, Collection<String> tableNames)
          Returns the Hibernate mapping document for the specified tables

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger

PACKAGE_NAME

protected static final String PACKAGE_NAME
See Also:
Constant Field Values
Constructor Detail

AutoMapper

public AutoMapper()
Method Detail

map

public static org.dom4j.Document map(Connection conn,
                                     String catalog,
                                     String schema,
                                     Collection<String> tableNames)
                              throws SQLException
Returns the Hibernate mapping document for the specified tables

To create the mapping, a Connection object must be provided to provide access to the specified tables. This connection will not be closed on return.

Parameters:
conn - JDBC Connection used during mapping
catalog - database catalog
schema - database schema
tableNames - list of table names
Returns:
the XML mapping document that maps the tables specified by the catalog, schema and tablenames arguments.
Throws:
SQLException

getClass

public static Class<?> getClass(String catalog,
                                String schema,
                                String tableName)
Returns the Class object to which the specified table is mapped

Parameters:
catalog - catalog of the table
schema - schema of the table
tableName - name of the table
Returns:
class to which the table specified by the arguments is mapped

getMappedTables

public static List<String[]> getMappedTables()
Returns the tables mapped by this automapper.

Returns:
a List of mapped tables. Each table is represented by a String array with the first component the catalog, the second the schema, and the third the table name.

getAttributes

public static List<String> getAttributes(String catalog,
                                         String schema,
                                         String tableName)
Returns the attribute names of the class to with the specified table is mapped

Parameters:
catalog - catalog of the table
schema - schema of the table
tableName - name of the table
Returns:
list of attribute (field) names of the class that corresponds with the table identified by the arguments

getIdAttribute

public static String getIdAttribute(String catalog,
                                    String schema,
                                    String tableName)
                             throws MissingIdentifierException
Returns the Identifier attribute

Parameters:
catalog - catalog of the table
schema - schema of the table
tableName - name of the table
Returns:
the attribute name which functions as a unique identifier for the objects corresponding to rows in the specified table
Throws:
MissingIdentifierException - when no Identifier property is available

getGeometryAttribute

public static String getGeometryAttribute(String catalog,
                                          String schema,
                                          String tableName)
                                   throws GeometryNotFoundException
Returns the (default) Geometry-valued attribute

Parameters:
catalog - catalog of the table
schema - schema of the table
tableName - name of the table
Returns:
the name of the Geometry-valued attribute
Throws:
GeometryNotFoundException - when no Geometry-valued property is available

getAttributeSetterName

public static String getAttributeSetterName(String catalog,
                                            String schema,
                                            String tableName,
                                            String attribute)
Returns the name of the setter-method for the attribute

Parameters:
catalog - catalog of the table
schema - schema of the table
tableName - name of the table
attribute - name of the attribute of the class to which this class is mapped
Returns:
the name of the setter-method of the attribute specified by the arguments

getAttributeGetterName

public static String getAttributeGetterName(String catalog,
                                            String schema,
                                            String tableName,
                                            String attribute)
Returns the name of the getter-method for the attribute

Parameters:
catalog - catalog of the table
schema - schema of the table
tableName - name of the table
attribute - name of the attribute of the class to which this class is mapped
Returns:
the name of the getter-method of the attribute specified by the arguments


Copyright © 2011 hibernatespatial.org. All Rights Reserved.