01: /**********************************************************************
02: Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: ...
18: **********************************************************************/package org.jpox.store.mapping;
19:
20: import org.jpox.store.DatastoreField;
21:
22: /**
23: * Mapping to represent a field that is mapped to multiple datastore columns.
24: * @version $Revision: 1.8 $
25: **/
26: public abstract class SingleFieldMultiMapping extends JavaTypeMapping {
27: /**
28: * Convenience method to add a datastore field for this mapping.
29: * The column will be created using the ColumnMetaData for the respective position
30: * of this column. The column is added to the end of the list of datastore fields.
31: * @param typeName Java type of the field to add the column for.
32: */
33: protected void addDatastoreField(String typeName) {
34: MappingManager mgr = dba.getMappingManager();
35: DatastoreField column = mgr.createDatastoreField(this ,
36: typeName, getNumberOfDatastoreFields());
37: mgr.createDatastoreMapping(this , datastoreContainer
38: .getStoreManager(), column, typeName);
39: }
40:
41: /**
42: * Accessor for the name of the java-type actually used when mapping the particular datastore
43: * field. This java-type must have an entry in the datastore mappings.
44: * @param index requested datastore field index.
45: * @return the name of java-type for the requested datastore field.
46: */
47: public String getJavaTypeForDatastoreMapping(int index) {
48: return datastoreMappings[index].getDatastoreField()
49: .getStoredJavaType();
50: }
51: }
|