rm-generator.1.5.0.source-code.bean_dml.vm Maven / Gradle / Ivy
The newest version!
## Velocity template to generate the bean DML for a respective generated Java Bean class
#if($class.isInterface())
package $class.InterfacePackageName;
#else
package $class.PackageName;
#end
import ${class.BeanPackageName}.*;
#if(!$class.isInterface())
import org.noorm.jdbc.*;
#end
import java.util.*;
#if(!$class.isInterface() && $class.hasInterface())
import ${class.InterfacePackageName}.I$class.getJavaName();
#end
/**
* Bean DML for all Java Beans generated in $class.PackageName
* DO NOT EDIT! This file has been auto-generated by NoORM
*/
#if($class.isInterface())
public interface I$class.getJavaName() {
#else
#if($class.hasInterface())
public class $class.getJavaName() implements I$class.getJavaName() {
#else
public class $class.getJavaName() {
#end
#end
#if(!$class.hasInterface())
private static $class.getJavaName() $class.getFirstLowerName() = new $class.getJavaName()();
#end
#if(!$class.isInterface())
#if ($class.hasDataSourceName())
private static final String DATA_SOURCE_NAME = "$class.getDataSourceName()";
#end
private final JDBCDMLProcessor typelessDMLProcessor = JDBCDMLProcessor.getInstance();
#end
#if(!$class.isInterface() && !$class.hasInterface())
protected $class.getJavaName()() {
}
public static $class.getJavaName() getInstance() {
return $class.getFirstLowerName();
}
#end
#if($class.isInterface())
$class.getDMLName() insert$class.getName()(final $class.getDMLName() p$class.getName());
void insert$class.getName()List(final List<$class.getDMLName()> p$class.getName()List);
$class.getDMLName() update$class.getName()(final $class.getDMLName() p$class.getName());
void update$class.getName()List(final List<$class.getDMLName()> p$class.getName()List);
void delete$class.getName()(final $class.getDMLName() p$class.getName());
void delete$class.getName()List(final List<$class.getDMLName()> p$class.getName()List);
#else
public $class.getDMLName() insert$class.getName()(final $class.getDMLName() p$class.getName()) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
final JDBCDMLProcessor<$class.getDMLName()> dmlProcessor = JDBCDMLProcessor.getInstance();
return dmlProcessor.insert(p$class.getName());
}
public void insert$class.getName()List(final List<$class.getDMLName()> p$class.getName()List) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.insert(p$class.getName()List);
}
public $class.getDMLName() update$class.getName()(final $class.getDMLName() p$class.getName()) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
final JDBCDMLProcessor<$class.getDMLName()> dmlProcessor = JDBCDMLProcessor.getInstance();
return dmlProcessor.update(p$class.getName());
}
public void update$class.getName()List(final List<$class.getDMLName()> p$class.getName()List) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.update(p$class.getName()List);
}
public void delete$class.getName()(final $class.getDMLName() p$class.getName()) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.delete(p$class.getName());
}
public void delete$class.getName()List(final List<$class.getDMLName()> p$class.getName()List) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.delete(p$class.getName()List);
}
#end
#foreach($update in $class.updates)
#if($class.isInterface())
int $update.getMethodName()(#foreach($param in $update.UpdateParameters)final $param.JavaType ${param.JavaName}#if($update.Parameters.size()>0),${nl}${subindent}#end#end
#foreach($param in $update.Parameters)#if(!$param.isUnaryOperator())final #if($param.isList())List<#end$param.JavaType#if($param.isList())>#end ${param.JavaName}#if($foreach.count<$update.Parameters.size()),${nl}${subindent}#end#end#end);
#else
public int $update.getMethodName()(#foreach($param in $update.UpdateParameters)final $param.JavaType ${param.JavaName}#if($update.Parameters.size()>0),${nl}${subindent}#end#end
#foreach($param in $update.Parameters)#if(!$param.isUnaryOperator())final #if($param.isList())List<#end$param.JavaType#if($param.isList())>#end ${param.JavaName}#if($foreach.count<$update.Parameters.size()),${nl}${subindent}#end#end#end) {
#if($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
final Map updateParameters = new HashMap();
#foreach ($param in $update.UpdateParameters)
updateParameters.put("$param.getDbParamName().toLowerCase()", $param.JavaName);
#end
final Map parameters = new HashMap();
#foreach ($param in $update.Parameters)
#if($param.isUnaryOperator())
parameters.put(new QueryColumn("$param.getDbParamName().toLowerCase()", new Operator(Operator.Name.$param.getOperator()),#if($param.hasCustomExpression()) "$param.getCustomExpression()"#else null#end), null);
#else
parameters.put(new QueryColumn("$param.getDbParamName().toLowerCase()", new Operator(Operator.Name.$param.getOperator()),#if($param.hasCustomExpression()) "$param.getCustomExpression()"#else null#end), $param.JavaName);
#end
#end
final JDBCDMLProcessor<$update.getBeanName()> dmlProcessor = JDBCDMLProcessor.getInstance();
return dmlProcessor.update("$update.getTableName()", updateParameters, parameters, ${update.getBeanName()}.class);
}
#end
#end
#foreach($delete in $class.deletes)
#if($class.isInterface())
int $delete.getMethodName()(#foreach($param in $delete.Parameters)#if(!$param.isUnaryOperator())final #if($param.isList())List<#end$param.JavaType#if($param.isList())>#end ${param.JavaName}#if($foreach.count<$delete.Parameters.size()),${nl}${subindent}#end#end#end);
#else
public int $delete.getMethodName()(#foreach($param in $delete.Parameters)#if(!$param.isUnaryOperator())final #if($param.isList())List<#end$param.JavaType#if($param.isList())>#end ${param.JavaName}#if($foreach.count<$delete.Parameters.size()),${nl}${subindent}#end#end#end) {
#if($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
final Map parameters = new HashMap();
#foreach ($param in $delete.Parameters)
#if($param.isUnaryOperator())
parameters.put(new QueryColumn("$param.getDbParamName().toLowerCase()", new Operator(Operator.Name.$param.getOperator()),#if($param.hasCustomExpression()) "$param.getCustomExpression()"#else null#end), null);
#else
parameters.put(new QueryColumn("$param.getDbParamName().toLowerCase()", new Operator(Operator.Name.$param.getOperator()),#if($param.hasCustomExpression()) "$param.getCustomExpression()"#else null#end), $param.JavaName);
#end
#end
final JDBCDMLProcessor<$delete.getBeanName()> dmlProcessor = JDBCDMLProcessor.getInstance();
return dmlProcessor.delete("$delete.getTableName()", parameters, ${delete.getBeanName()}.class);
}
#end
#end
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy