Package org.castor.ddlgen
Class MappingHelper
java.lang.Object
org.castor.ddlgen.MappingHelper
This class handles all common tasks for manipulating Mapping document.
- Since:
- 1.1
- Version:
- $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
- Author:
- Le Duc Bao, Ralf Joachim
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetClassMappingByName
(String name) Return the ClassMapping which associated with parameter name.String[]
The identity definitions at class and field are alternative syntax.String[]
getClassMappingSqlIdentity
(ClassMapping cm, boolean ext) The identity definitions at class and field are alternative syntax.Get mapping document.Get type mapper.boolean
isIdentity
(ClassMapping cm, FieldMapping fm) Check if given FieldMapping is an identity at given ClassMapping.boolean
Check if identities of given ClassMapping are defined at its FieldMappings.String[]
resolveTypeReferenceForIds
(String className) Collect sql type of all identities for class with given name.String[]
Collect sql type of all identities for a ClassMapping.void
setMapping
(Mapping mapping) set mapping document.void
setTypeMapper
(TypeMapper typeMapper) Set type mapper.
-
Constructor Details
-
MappingHelper
public MappingHelper()
-
-
Method Details
-
getMapping
Get mapping document.- Returns:
- Mapping document.
-
setMapping
set mapping document.- Parameters:
mapping
- Mapping document.
-
getTypeMapper
Get type mapper.- Returns:
- Type mapper.
-
setTypeMapper
Set type mapper.- Parameters:
typeMapper
- Type mapper.
-
getClassMappingByName
Return the ClassMapping which associated with parameter name.- Parameters:
name
- Name of class to get ClassMapping of.- Returns:
- ClassMapping of the named class or
null
if no such ClassMapping was found.
-
resolveTypeReferenceForIds
Collect sql type of all identities for class with given name. It also takes care on multiple column identities and extended classes.<mapping> <class name="myapp.OtherProductGroup" > <map-to table="other_prod_group" xml="group" /> <field name="id" type="integer" identity="true"> <sql name="id" type="integer"/> </field> </class> <class name="myapp.ProductGroup" identity="id"> <map-to table="prod_group" xml="group" /> <field name="id" type="myapp.OtherProductGroup" > <sql name="prod_id" /> </field> </class> <class name="myapp.Product" identity="id"> <field name="group" type="myapp.ProductGroup"> <sql name="group_id" /> </field> </class> </mapping>
- Parameters:
className
- Name of class to get type of identities of.- Returns:
- Array of sql types of all identities.
- Throws:
GeneratorException
- If failed to resolve sql type of identities.
-
resolveTypeReferenceForIds
Collect sql type of all identities for a ClassMapping. It also takes care on multiple column identities and extended classes.- Parameters:
cm
- ClassMapping to get type of identities of.- Returns:
- Array of sql types of all identities.
- Throws:
GeneratorException
- If failed to resolve sql type of identities.
-
isUseFieldIdentity
Check if identities of given ClassMapping are defined at its FieldMappings.- Parameters:
cm
- ClassMapping to check for identity definitions at FieldMapping.- Returns:
true
if identities are defined at fieldMapping.
-
isIdentity
Check if given FieldMapping is an identity at given ClassMapping.<class name="myapp.ProductGroup" identity="id"> <field name="id" type="integer" > <sql name="id1 id2" type="integer"/> </field> </class>
- Parameters:
cm
- ClassMapping.fm
- FieldMapping.- Returns:
true
if FieldMapping is an identity at ClassMapping.
-
getClassMappingSqlIdentity
The identity definitions at class and field are alternative syntax. If both are specified the one at field should take precedence over the class one. In other words if both are specified the one at class will be ignored.- Parameters:
cm
- ClassMapping to get sql names of identities of.ext
- Recursivly search for identities in extended ClassMappings.- Returns:
- Array of sql names of identities of given ClassMapping.
-
getClassMappingIdentity
The identity definitions at class and field are alternative syntax. If both are specified the one at field should take precedence over the class one. In other words if both are specified the one at class will be ignored.- Parameters:
cm
- ClassMapping to get identity names of.- Returns:
- Array of identity names of given ClassMapping.
-