## Licensed to the Apache Software Foundation (ASF) under one ## or more contributor license agreements. See the NOTICE file ## distributed with this work for additional information ## regarding copyright ownership. The ASF licenses this file ## to you under the Apache License, Version 2.0 (the ## "License"); you may not use this file except in compliance ## with the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, ## software distributed under the License is distributed on an ## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ## KIND, either express or implied. See the License for the ## specific language governing permissions and limitations ## under the License. ## ##Terminology: ## Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass ## Super class - superclass of entity, ie, org.apache.cayenne.art.auto._Artist ## Sub class - class of entity, ie, org.apache.cayenne.art.Artist ## ## Classes available in template ## stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils ## dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils ## importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils ## superClassName ## superPackageName ## subClassName ## subPackageName ## baseClassName ## basePackageName ## ${importUtils.setPackage($superPackageName)}## #if(${superPackageName})${importUtils.addReservedType("${superPackageName}.${superClassName}")}#end## #if(${basePackageName})${importUtils.addType("${basePackageName}.${baseClassName}")}#end## #if( ${object.hasSelectQueries()} ) ${importUtils.addType('java.util.List')}## ${importUtils.addType('org.apache.cayenne.ObjectContext')}## ${importUtils.addType('org.apache.cayenne.query.NamedQuery')}## #foreach( $selectQuery in ${object.SelectQueries}) ${importUtils.addType(${selectQuery.Root.ClientClassName})}## #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}) ${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}## #end #end #end ${importUtils.generate()} /** * This class was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public class ${superClassName} { #if( ${object.hasQueryNames()}) #foreach( $qname in ${object.QueryNames}) public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname"; #end #end #foreach( $selectQuery in ${object.SelectQueries}) public List<${stringUtils.stripPackageName($selectQuery.Root.ClientClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter}#end) { #if(${dataMapUtils.hasParameters($selectQuery)}) String[] parameters = { #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}) "${parameter}", #end }; Object[] values = { #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}) ${parameter}, #end }; #end return context.performQuery(new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end)); } #end }