rm-generator.1.2.1.source-code.bean_dml.vm Maven / Gradle / Ivy
## Velocity template to generate the bean DML for all generated Java Bean classes
#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}.${class.JavaInterfaceName};
#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 IBeanDML {
#else
#if($class.hasInterface())
public class BeanDML implements IBeanDML {
#else
public class BeanDML {
#end
#end
#if(!$class.hasInterface())
private static BeanDML beanDML = new BeanDML();
#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 BeanDML() {
}
public static BeanDML getInstance() {
return beanDML;
}
#end
#foreach ($bean in $class.Beans)
#if($bean.isUpdatable())
#if($class.isInterface())
$bean.getDMLName() insert$bean.getName()(final $bean.getDMLName() p$bean.getName());
void insert$bean.getName()List(final List<$bean.getDMLName()> p$bean.getName()List);
$bean.getDMLName() update$bean.getName()(final $bean.getDMLName() p$bean.getName());
void update$bean.getName()List(final List<$bean.getDMLName()> p$bean.getName()List);
void delete$bean.getName()(final $bean.getDMLName() p$bean.getName());
void delete$bean.getName()List(final List<$bean.getDMLName()> p$bean.getName()List);
#else
public $bean.getDMLName() insert$bean.getName()(final $bean.getDMLName() p$bean.getName()) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
final JDBCDMLProcessor<$bean.getDMLName()> dmlProcessor = JDBCDMLProcessor.getInstance();
return dmlProcessor.insert(p$bean.getName());
}
public void insert$bean.getName()List(final List<$bean.getDMLName()> p$bean.getName()List) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.insert(p$bean.getName()List);
}
public $bean.getDMLName() update$bean.getName()(final $bean.getDMLName() p$bean.getName()) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
final JDBCDMLProcessor<$bean.getDMLName()> dmlProcessor = JDBCDMLProcessor.getInstance();
return dmlProcessor.update(p$bean.getName());
}
public void update$bean.getName()List(final List<$bean.getDMLName()> p$bean.getName()List) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.update(p$bean.getName()List);
}
public void delete$bean.getName()(final $bean.getDMLName() p$bean.getName()) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.delete(p$bean.getName());
}
public void delete$bean.getName()List(final List<$bean.getDMLName()> p$bean.getName()List) {
#if ($class.hasDataSourceName())
DataSourceProvider.setActiveDataSource(DATA_SOURCE_NAME);
#end
typelessDMLProcessor.delete(p$bean.getName()List);
}
#end
#end
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy