Home » apache-openjpa-1.1.0-source » org.apache.openjpa.jdbc » meta » strats » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    * http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.    
   18    */
   19   package org.apache.openjpa.jdbc.meta.strats;
   20   
   21   import java.sql.SQLException;
   22   
   23   import org.apache.openjpa.conf.OpenJPAConfiguration;
   24   import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
   25   import org.apache.openjpa.jdbc.kernel.JDBCStore;
   26   import org.apache.openjpa.jdbc.meta.ClassMapping;
   27   import org.apache.openjpa.jdbc.meta.FieldMapping;
   28   import org.apache.openjpa.jdbc.schema.Column;
   29   import org.apache.openjpa.jdbc.schema.ForeignKey;
   30   import org.apache.openjpa.jdbc.sql.Joins;
   31   import org.apache.openjpa.jdbc.sql.Result;
   32   import org.apache.openjpa.jdbc.sql.Select;
   33   import org.apache.openjpa.kernel.OpenJPAStateManager;
   34   import org.apache.openjpa.lib.util.Localizer;
   35   import org.apache.openjpa.meta.JavaTypes;
   36   import org.apache.openjpa.util.MetaDataException;
   37   import org.apache.openjpa.util.Proxy;
   38   
   39   /**
   40    * Maps a relation to a collection of other objects using an inverse
   41    * foreign key in the related object table.
   42    *
   43    * @author Abe White
   44    */
   45   public class RelationCollectionInverseKeyFieldStrategy
   46       extends RelationToManyInverseKeyFieldStrategy
   47       implements LRSCollectionFieldStrategy {
   48   
   49       private static final Localizer _loc = Localizer.forPackage
   50           (RelationCollectionInverseKeyFieldStrategy.class);
   51   
   52       public FieldMapping getFieldMapping() {
   53           return field;
   54       }
   55   
   56       public ClassMapping[] getIndependentElementMappings(boolean traverse) {
   57           return super.getIndependentElementMappings(traverse);
   58       }
   59   
   60       public Column[] getElementColumns(ClassMapping elem) {
   61           return elem.getPrimaryKeyColumns();
   62       }
   63   
   64       public ForeignKey getJoinForeignKey(ClassMapping elem) {
   65           return super.getJoinForeignKey(elem);
   66       }
   67   
   68       public void selectElement(Select sel, ClassMapping elem, JDBCStore store,
   69           JDBCFetchConfiguration fetch, int eagerMode, Joins joins) {
   70           super.selectElement(sel, elem, store, fetch, eagerMode, joins);
   71       }
   72   
   73       public Object loadElement(OpenJPAStateManager sm, JDBCStore store,
   74           JDBCFetchConfiguration fetch, Result res, Joins joins)
   75           throws SQLException {
   76           return super.loadElement(sm, store, fetch, res, joins);
   77       }
   78   
   79       public Joins join(Joins joins, ClassMapping elem) {
   80           return super.join(joins, elem);
   81       }
   82   
   83       public Joins joinElementRelation(Joins joins, ClassMapping elem) {
   84           return super.joinElementRelation(joins, elem);
   85       }
   86   
   87       protected Proxy newLRSProxy() {
   88           return new LRSProxyCollection(this);
   89       }
   90   
   91       public void map(boolean adapt) {
   92           if (field.getTypeCode() != JavaTypes.COLLECTION
   93               && field.getTypeCode() != JavaTypes.ARRAY)
   94               throw new MetaDataException(_loc.get("not-coll", field));
   95           super.map(adapt);
   96       }
   97   }

Save This Page
Home » apache-openjpa-1.1.0-source » org.apache.openjpa.jdbc » meta » strats » [javadoc | source]