You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(11) |
Oct
(10) |
Nov
(3) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(44) |
Feb
(30) |
Mar
(11) |
Apr
(43) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(9) |
Oct
|
Nov
(1) |
Dec
(1) |
2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
(17) |
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <rfl...@us...> - 2006-10-13 17:34:24
|
Revision: 194 http://svn.sourceforge.net/salto-db/?rev=194&view=rev Author: rflament Date: 2006-10-13 10:34:02 -0700 (Fri, 13 Oct 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/templates/ejb3/dataobject.vm salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm salto-db-generator/trunk/templates/hibernateejb3dao/abstracthibernatedao.vm salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm salto-db-generator/trunk/templates/hibernateejb3dao/daofactory.vm salto-db-generator/trunk/templates/hibernateejb3dao/genericdao.vm salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedaofactory.vm salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm Modified: salto-db-generator/trunk/templates/ejb3/dataobject.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/dataobject.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/ejb3/dataobject.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -29,7 +29,7 @@ * ${jdoInfo.getTableRemarks()} * * Generated at $date - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} * */ #if ($annotations=="true") Modified: salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -32,7 +32,7 @@ #end #else #foreach($jdoInfo in ${jdoInfos}) - <mapping file="${jdoInfo.javaClassName}.hbm.xml" /> + <mapping resource="${jdoInfo.javaClassName}.hbm.xml" /> #end #end Modified: salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm =================================================================== --- salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -1,10 +1,10 @@ -<!DOCTYPE hibernate-configuration PUBLIC - "-//Hibernate/Hibernate Configuration DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> +<!DOCTYPE hibernate-mapping PUBLIC + "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- This file has been generated by ${generatorVersion} at $date --> -<hibernate-mapping package="${jdoInfo.javaPckName}"> - <class name="${jdoInfo.javaClassName}" table="${jdoInfo.tableName}"> +<hibernate-mapping> + <class name="${jdoInfo.javaPckName}.${jdoInfo.javaClassName}" table="${jdoInfo.tableName}"> #set( $sprimarykeydone = "false" ) #foreach($col in ${jdoInfo.jdoColInfos}) @@ -37,7 +37,7 @@ #foreach($colpk in ${jdoInfo.getPk()}) #if ($colpk.col.equals($col.colName)) #if ($sprimarykeydone=="false") - <composite-id name="id" class="${jdoInfo.javaClassName}\$${jdoInfo.javaClassName}PK"> + <composite-id name="${util.DoNameCreator.class2attribute($jdoInfo.javaClassName)}PK" class="${jdoInfo.javaPckName}.${jdoInfo.javaClassName}\$${jdoInfo.javaClassName}PK"> #foreach($col in ${jdoInfo.jdoColInfos}) #foreach($colpk in ${jdoInfo.getPk()}) #if ($colpk.col.equals($col.colName)) @@ -77,24 +77,24 @@ #if ($util.getLength($colfk) > 1) #foreach($colfk2 in $colfk) #if ($fkdone=="false") - <set name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s" inverse="true"> + <bag name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s" inverse="true"> <key> #foreach($colfk3 in $colfk) <column name="$colfk3.getFkColumnName()"/> #end </key> - <one-to-many class="$util.DoNameCreator.createDoName($colfk2.getFkTableName())"/> - </set> + <one-to-many class="${jdoInfo.javaPckName}.$util.DoNameCreator.createDoName($colfk2.getFkTableName())"/> + </bag> #set ($fkdone="true") #end #end #else #foreach($colfk2 in $colfk) - <set name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s" inverse="true"> + <bag name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s" inverse="true"> <key column="$colfk2.getFkColumnName()"/> - <one-to-many class="$util.DoNameCreator.createDoName($colfk2.getFkTableName())"/> - </set> + <one-to-many class="${jdoInfo.javaPckName}.$util.DoNameCreator.createDoName($colfk2.getFkTableName())"/> + </bag> #end #end Modified: salto-db-generator/trunk/templates/hibernateejb3dao/abstracthibernatedao.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/abstracthibernatedao.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/abstracthibernatedao.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -10,7 +10,7 @@ /** * Generated at $date * - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public abstract class AbstractHibernateDAO<T, ID extends Serializable> implements GenericDAO<T, ID> { Modified: salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -21,7 +21,7 @@ /** * Generated at $date * - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public interface ${jdoInfo.javaClassName}DAO extends GenericDAO<${jdoInfo.javaClassName},$pk> { Modified: salto-db-generator/trunk/templates/hibernateejb3dao/daofactory.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/daofactory.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/daofactory.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -6,7 +6,7 @@ * Generated at $date * * @see http://www.hibernate.org/328.html - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public abstract class DAOFactory { Modified: salto-db-generator/trunk/templates/hibernateejb3dao/genericdao.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/genericdao.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/genericdao.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -6,7 +6,7 @@ /** * Generated at $date * - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public interface GenericDAO<T, ID extends Serializable> { Modified: salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -27,7 +27,7 @@ /** * Generated at $date * - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public class ${jdoInfo.javaClassName}HibernateDAO extends AbstractHibernateDAO<${jdoInfo.javaClassName}, $pk> implements Modified: salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedaofactory.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedaofactory.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedaofactory.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -9,7 +9,7 @@ * Generated at $date * * @see http://www.hibernate.org/43.html - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public class HibernateDAOFactory extends DAOFactory { Modified: salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm 2006-10-09 17:58:46 UTC (rev 193) +++ salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm 2006-10-13 17:34:02 UTC (rev 194) @@ -3,12 +3,16 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; +#if ($annotations=="true") import org.hibernate.cfg.AnnotationConfiguration; +#else +import org.hibernate.cfg.Configuration; +#end /** * Generated at $date * - * @author salto-db-generator ${generatorVersion} + * @author ${generatorVersion} */ public final class HibernateUtil { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-10-09 17:58:59
|
Revision: 193 http://svn.sourceforge.net/salto-db/?rev=193&view=rev Author: rflament Date: 2006-10-09 10:58:46 -0700 (Mon, 09 Oct 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/test/build-ejb3.xml Added Paths: ----------- salto-db-generator/trunk/test/build-EJB3AndHibernateDAO.xml salto-db-generator/trunk/test/build-PojoHibernateDAO.xml salto-db-generator/trunk/test/build-hibernate.xml salto-db-generator/trunk/test/build-saltodb.xml Removed Paths: ------------- salto-db-generator/trunk/test/build-HibernateEJB3AndDAO.xml salto-db-generator/trunk/test/build-sdb.xml Copied: salto-db-generator/trunk/test/build-EJB3AndHibernateDAO.xml (from rev 190, salto-db-generator/trunk/test/build-HibernateEJB3AndDAO.xml) =================================================================== --- salto-db-generator/trunk/test/build-EJB3AndHibernateDAO.xml (rev 0) +++ salto-db-generator/trunk/test/build-EJB3AndHibernateDAO.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -0,0 +1,41 @@ +<project name="salto-db-ant-test" basedir=".." default="generate"> + + + <!-- set the name of your database schema --> + <property name="schema" value=""/> + + <!-- set a pattern to search for tables. You can use the joker character '%'. If you want to generate DataObjects for every tables, just set '%' --> + <property name="tableName" value=""/> + + <!-- set your database username--> + <property name="login" value=""/> + + <!-- set your database password--> + <property name="password" value=""/> + + <!-- set your jdbc url to access the database--> + <property name="jdbcUrl" value=""/> + + <!-- set the jdbc driver class name to access to your database. This class should be in the classpath of the taskdef. You can copy the jar file in lib.--> + <property name="driverClassName" value=""/> + + <!-- set the path where to generate DataObjects source code--> + <property name="outputDir" value="generated-src"/> + + <!-- set the package name in which to generate DataObjects--> + <property name="packageName" value="com"/> + + <path id="lib.path"> + <fileset dir="lib" includes="*.jar"/> + <fileset dir="." includes="*.jar"/> + </path> + + <taskdef name="salto-db-generate" classname="com.salto.db.ant.DOGeneratorTask" classpathref="lib.path"/> + + <target name="generate"> + <salto-db-generate plugin="EJB3AndHibernateDao" schema="${schema}" tableName="${tableName}" login="${login}" password="${password}" jdbcUrl="${jdbcUrl}" driverClassName="${driverClassName}" + outputDir="${outputDir}" packageName="${packageName}"/> + </target> + + +</project> \ No newline at end of file Deleted: salto-db-generator/trunk/test/build-HibernateEJB3AndDAO.xml =================================================================== --- salto-db-generator/trunk/test/build-HibernateEJB3AndDAO.xml 2006-10-09 17:56:36 UTC (rev 192) +++ salto-db-generator/trunk/test/build-HibernateEJB3AndDAO.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -1,41 +0,0 @@ -<project name="salto-db-ant-test" basedir=".." default="generate"> - - - <!-- set the name of your database schema --> - <property name="schema" value=""/> - - <!-- set a pattern to search for tables. You can use the joker character '%'. If you want to generate DataObjects for every tables, just set '%' --> - <property name="tableName" value=""/> - - <!-- set your database username--> - <property name="login" value=""/> - - <!-- set your database password--> - <property name="password" value=""/> - - <!-- set your jdbc url to access the database--> - <property name="jdbcUrl" value=""/> - - <!-- set the jdbc driver class name to access to your database. This class should be in the classpath of the taskdef. You can copy the jar file in lib.--> - <property name="driverClassName" value=""/> - - <!-- set the path where to generate DataObjects source code--> - <property name="outputDir" value="generated-src"/> - - <!-- set the package name in which to generate DataObjects--> - <property name="packageName" value=""/> - - <path id="lib.path"> - <fileset dir="lib" includes="*.jar"/> - <fileset dir="." includes="*.jar"/> - </path> - - <taskdef name="salto-db-generate" classname="com.salto.db.ant.DOGeneratorTask" classpathref="lib.path"/> - - <target name="generate"> - <salto-db-generate plugin="HibernateEJB3AndDao" schema="${schema}" tableName="${tableName}" login="${login}" password="${password}" jdbcUrl="${jdbcUrl}" driverClassName="${driverClassName}" - outputDir="${outputDir}" packageName="${packageName}"/> - </target> - - -</project> \ No newline at end of file Added: salto-db-generator/trunk/test/build-PojoHibernateDAO.xml =================================================================== --- salto-db-generator/trunk/test/build-PojoHibernateDAO.xml (rev 0) +++ salto-db-generator/trunk/test/build-PojoHibernateDAO.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -0,0 +1,41 @@ +<project name="salto-db-ant-test" basedir=".." default="generate"> + + + <!-- set the name of your database schema --> + <property name="schema" value=""/> + + <!-- set a pattern to search for tables. You can use the joker character '%'. If you want to generate DataObjects for every tables, just set '%' --> + <property name="tableName" value=""/> + + <!-- set your database username--> + <property name="login" value=""/> + + <!-- set your database password--> + <property name="password" value=""/> + + <!-- set your jdbc url to access the database--> + <property name="jdbcUrl" value=""/> + + <!-- set the jdbc driver class name to access to your database. This class should be in the classpath of the taskdef. You can copy the jar file in lib.--> + <property name="driverClassName" value=""/> + + <!-- set the path where to generate DataObjects source code--> + <property name="outputDir" value="generated-src"/> + + <!-- set the package name in which to generate DataObjects--> + <property name="packageName" value="com.dao.hibernate"/> + + <path id="lib.path"> + <fileset dir="lib" includes="*.jar"/> + <fileset dir="." includes="*.jar"/> + </path> + + <taskdef name="salto-db-generate" classname="com.salto.db.ant.DOGeneratorTask" classpathref="lib.path"/> + + <target name="generate"> + <salto-db-generate plugin="PojoHibernateDao" schema="${schema}" tableName="${tableName}" login="${login}" password="${password}" jdbcUrl="${jdbcUrl}" driverClassName="${driverClassName}" + outputDir="${outputDir}" packageName="${packageName}"/> + </target> + + +</project> \ No newline at end of file Modified: salto-db-generator/trunk/test/build-ejb3.xml =================================================================== --- salto-db-generator/trunk/test/build-ejb3.xml 2006-10-09 17:56:36 UTC (rev 192) +++ salto-db-generator/trunk/test/build-ejb3.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -23,7 +23,7 @@ <property name="outputDir" value="generated-src"/> <!-- set the package name in which to generate DataObjects--> - <property name="packageName" value=""/> + <property name="packageName" value="com"/> <path id="lib.path"> <fileset dir="lib" includes="*.jar"/> Added: salto-db-generator/trunk/test/build-hibernate.xml =================================================================== --- salto-db-generator/trunk/test/build-hibernate.xml (rev 0) +++ salto-db-generator/trunk/test/build-hibernate.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -0,0 +1,41 @@ +<project name="salto-db-ant-test" basedir=".." default="generate"> + + + <!-- set the name of your database schema --> + <property name="schema" value=""/> + + <!-- set a pattern to search for tables. You can use the joker character '%'. If you want to generate DataObjects for every tables, just set '%' --> + <property name="tableName" value=""/> + + <!-- set your database username--> + <property name="login" value=""/> + + <!-- set your database password--> + <property name="password" value=""/> + + <!-- set your jdbc url to access the database--> + <property name="jdbcUrl" value=""/> + + <!-- set the jdbc driver class name to access to your database. This class should be in the classpath of the taskdef. You can copy the jar file in lib.--> + <property name="driverClassName" value=""/> + + <!-- set the path where to generate DataObjects source code--> + <property name="outputDir" value="generated-src"/> + + <!-- set the package name in which to generate DataObjects--> + <property name="packageName" value="com"/> + + <path id="lib.path"> + <fileset dir="lib" includes="*.jar"/> + <fileset dir="." includes="*.jar"/> + </path> + + <taskdef name="salto-db-generate" classname="com.salto.db.ant.DOGeneratorTask" classpathref="lib.path"/> + + <target name="generate"> + <salto-db-generate plugin="Hibernate" schema="${schema}" tableName="${tableName}" login="${login}" password="${password}" jdbcUrl="${jdbcUrl}" driverClassName="${driverClassName}" + outputDir="${outputDir}" packageName="${packageName}"/> + </target> + + +</project> \ No newline at end of file Copied: salto-db-generator/trunk/test/build-saltodb.xml (from rev 190, salto-db-generator/trunk/test/build-sdb.xml) =================================================================== --- salto-db-generator/trunk/test/build-saltodb.xml (rev 0) +++ salto-db-generator/trunk/test/build-saltodb.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -0,0 +1,41 @@ +<project name="salto-db-ant-test" basedir=".." default="generate"> + + + <!-- set the name of your database schema --> + <property name="schema" value=""/> + + <!-- set a pattern to search for tables. You can use the joker character '%'. If you want to generate DataObjects for every tables, just set '%' --> + <property name="tableName" value=""/> + + <!-- set your database username--> + <property name="login" value=""/> + + <!-- set your database password--> + <property name="password" value=""/> + + <!-- set your jdbc url to access the database--> + <property name="jdbcUrl" value=""/> + + <!-- set the jdbc driver class name to access to your database. This class should be in the classpath of the taskdef. You can copy the jar file in lib.--> + <property name="driverClassName" value=""/> + + <!-- set the path where to generate DataObjects source code--> + <property name="outputDir" value="generated-src"/> + + <!-- set the package name in which to generate DataObjects--> + <property name="packageName" value="com.saltodb"/> + + <path id="lib.path"> + <fileset dir="lib" includes="*.jar"/> + <fileset dir="." includes="*.jar"/> + </path> + + <taskdef name="salto-db-generate" classname="com.salto.db.ant.DOGeneratorTask" classpathref="lib.path"/> + + <target name="generate"> + <salto-db-generate plugin="Salto-db" schema="${schema}" tableName="${tableName}" login="${login}" password="${password}" jdbcUrl="${jdbcUrl}" driverClassName="${driverClassName}" + outputDir="${outputDir}" packageName="${packageName}"/> + </target> + + +</project> \ No newline at end of file Deleted: salto-db-generator/trunk/test/build-sdb.xml =================================================================== --- salto-db-generator/trunk/test/build-sdb.xml 2006-10-09 17:56:36 UTC (rev 192) +++ salto-db-generator/trunk/test/build-sdb.xml 2006-10-09 17:58:46 UTC (rev 193) @@ -1,41 +0,0 @@ -<project name="salto-db-ant-test" basedir=".." default="generate"> - - - <!-- set the name of your database schema --> - <property name="schema" value=""/> - - <!-- set a pattern to search for tables. You can use the joker character '%'. If you want to generate DataObjects for every tables, just set '%' --> - <property name="tableName" value=""/> - - <!-- set your database username--> - <property name="login" value=""/> - - <!-- set your database password--> - <property name="password" value=""/> - - <!-- set your jdbc url to access the database--> - <property name="jdbcUrl" value=""/> - - <!-- set the jdbc driver class name to access to your database. This class should be in the classpath of the taskdef. You can copy the jar file in lib.--> - <property name="driverClassName" value=""/> - - <!-- set the path where to generate DataObjects source code--> - <property name="outputDir" value="generated-src"/> - - <!-- set the package name in which to generate DataObjects--> - <property name="packageName" value=""/> - - <path id="lib.path"> - <fileset dir="lib" includes="*.jar"/> - <fileset dir="." includes="*.jar"/> - </path> - - <taskdef name="salto-db-generate" classname="com.salto.db.ant.DOGeneratorTask" classpathref="lib.path"/> - - <target name="generate"> - <salto-db-generate plugin="Salto-db" schema="${schema}" tableName="${tableName}" login="${login}" password="${password}" jdbcUrl="${jdbcUrl}" driverClassName="${driverClassName}" - outputDir="${outputDir}" packageName="${packageName}"/> - </target> - - -</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-10-09 17:57:00
|
Revision: 192 http://svn.sourceforge.net/salto-db/?rev=192&view=rev Author: rflament Date: 2006-10-09 10:56:36 -0700 (Mon, 09 Oct 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/templates/ejb3/dataobject.vm salto-db-generator/trunk/templates/ejb3/setter.vm salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm Added Paths: ----------- salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm salto-db-generator/trunk/templates/hibernate/ salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm Modified: salto-db-generator/trunk/templates/ejb3/dataobject.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/dataobject.vm 2006-10-09 17:55:54 UTC (rev 191) +++ salto-db-generator/trunk/templates/ejb3/dataobject.vm 2006-10-09 17:56:36 UTC (rev 192) @@ -4,6 +4,7 @@ import java.io.Serializable; import java.sql.Timestamp; +#if ($annotations=="true") import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -17,6 +18,7 @@ import javax.persistence.OneToMany; import javax.persistence.Transient; import javax.persistence.Embeddable; +#end /** #if ($jdoInfo.tableShem) @@ -30,6 +32,7 @@ * @author salto-db-generator ${generatorVersion} * */ +#if ($annotations=="true") @Entity #if ($jdoInfo.tableCat) #if ($jdoInfo.tableShem) @@ -45,6 +48,7 @@ #end #end @SuppressWarnings("serial") +#end public class ${jdoInfo.javaClassName} implements Serializable { #parse("${templatePath}/variable.vm") @@ -58,8 +62,10 @@ * Generated at $date * @author salto-db-generator ${generatorVersion} */ +#if ($annotations=="true") @SuppressWarnings("serial") @Embeddable +#end public static class ${jdoInfo.javaClassName}PK implements Serializable { #foreach($col in ${jdoInfo.jdoColInfos}) @@ -79,7 +85,9 @@ /** * Return ${col.javaAttName} */ +#if ($annotations=="true") @Column(name = "$col.colName") +#end public $col.javaAttClass ${col.getterMethod()}() { return ${col.javaAttName}; } @@ -98,7 +106,9 @@ /** * calculate hashcode */ +#if ($annotations=="true") @Override +#end public int hashCode() { //TODO : implement this method @@ -108,7 +118,9 @@ /** * equals method */ +#if ($annotations=="true") @Override +#end public boolean equals(Object object) { //TODO : implement this method Added: salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm (rev 0) +++ salto-db-generator/trunk/templates/ejb3/hibernate.cfg.xml.vm 2006-10-09 17:56:36 UTC (rev 192) @@ -0,0 +1,40 @@ +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> + +<!-- This file has been generated by ${generatorVersion} at $date --> +<hibernate-configuration> + <session-factory> + + <!-- You need to complete the configuration here. This is just a sample, you should use a connection pool --> + <property name="connection.url">${connInfo.url}</property> + <property name="connection.username">${connInfo.user}</property> + <property name="connection.driver_class">${connInfo.driver}</property> +#if ($dialect.getDialect(${connInfo.conn.getMetaData().getDatabaseProductName()})) + <!-- Your database is ${connInfo.conn.getMetaData().getDatabaseProductName()}--> + <property name="dialect">$dialect.getDialect(${connInfo.conn.getMetaData().getDatabaseProductName()})</property> +#else + <!-- Your database is ${connInfo.conn.getMetaData().getDatabaseProductName()}. No dialect is known by Salto-db-generator for this database. + If you know what dialect to use, please send an email to rfl...@sa... and precise that the database is + "${connInfo.conn.getMetaData().getDatabaseProductName()}". Thank you. + --> + <property name="dialect"> SET THE DATABASE DIALECT HERE </property> +#end + <property name="connection.password">${connInfo.pwd}</property> + <property name="show_sql">true</property> + +#if ($annotations=="true") +#foreach($jdoInfo in ${jdoInfos}) + <mapping class="${pckName}.${jdoInfo.javaClassName}" /> +#if ($util.getLength($jdoInfo.getPk()) > 1) + <mapping class="${pckName}.${jdoInfo.javaClassName}\$${jdoInfo.javaClassName}PK" /> +#end +#end +#else +#foreach($jdoInfo in ${jdoInfos}) + <mapping file="${jdoInfo.javaClassName}.hbm.xml" /> +#end +#end + + </session-factory> +</hibernate-configuration> Modified: salto-db-generator/trunk/templates/ejb3/setter.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/setter.vm 2006-10-09 17:55:54 UTC (rev 191) +++ salto-db-generator/trunk/templates/ejb3/setter.vm 2006-10-09 17:56:36 UTC (rev 192) @@ -10,7 +10,10 @@ /** * get ${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))} */ +#if ($annotations=="true") @ManyToOne +#end +#if ($annotations=="true") #if ($util.getLength($colfk) > 1) @JoinColumns({ #set ($i=1) @@ -26,6 +29,7 @@ #else @JoinColumn(name = "$col.colName") #end +#end public ${util.DoNameCreator.createDoName($colfk2.getPkTableName())} get${util.DoNameCreator.createDoName($colfk2.getPkTableName())}() { return this.${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))}; } @@ -51,8 +55,10 @@ /** * Get the primary key */ +#if ($annotations=="true") @Basic @Id +#end public ${jdoInfo.javaClassName}PK get${jdoInfo.javaClassName}PK() { return this.${util.DoNameCreator.class2attribute($jdoInfo.javaClassName)}PK; } @@ -69,7 +75,9 @@ /** * @return ${col.javaAttName} */ +#if ($annotations=="true") @Transient +#end public $col.getNonPrimitifClass() ${col.getterMethod()}() { return this.${util.DoNameCreator.class2attribute($jdoInfo.javaClassName)}PK.${col.getterMethod()}(); } @@ -83,6 +91,7 @@ /** * @return ${col.javaAttName} */ +#if ($annotations=="true") @Basic #foreach($colpk in ${jdoInfo.getPk()}) #if ($colpk.col.equals($col.colName)) @@ -93,6 +102,7 @@ @GeneratedValue #end @Column(name = "$col.colName") +#end public $col.getNonPrimitifClass() ${col.getterMethod()}() { return ${col.javaAttName}; } @@ -114,6 +124,7 @@ /** * Get the list of $util.DoNameCreator.createDoName($colfk2.getFkTableName()) */ +#if ($annotations=="true") @OneToMany @JoinColumns({ #set ($i=1) @@ -126,6 +137,7 @@ #set ($i = $i+1) #end }) +#end public List<$util.DoNameCreator.createDoName($colfk2.getFkTableName())> get$util.DoNameCreator.createDoName($colfk2.getFkTableName())s() { return this.${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s; } @@ -144,8 +156,10 @@ /** * Get the list of $util.DoNameCreator.createDoName($colfk2.getFkTableName()) */ +#if ($annotations=="true") @OneToMany @JoinColumn(name = "$colfk2.getFkColumnName()") +#end public List<$util.DoNameCreator.createDoName($colfk2.getFkTableName())> get$util.DoNameCreator.createDoName($colfk2.getFkTableName())s() { return this.${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s; } Added: salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm =================================================================== --- salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm (rev 0) +++ salto-db-generator/trunk/templates/hibernate/mapping.hbm.vm 2006-10-09 17:56:36 UTC (rev 192) @@ -0,0 +1,103 @@ +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> + +<!-- This file has been generated by ${generatorVersion} at $date --> +<hibernate-mapping package="${jdoInfo.javaPckName}"> + <class name="${jdoInfo.javaClassName}" table="${jdoInfo.tableName}"> + +#set( $sprimarykeydone = "false" ) +#foreach($col in ${jdoInfo.jdoColInfos}) +#set( $done = "false" ) +#if ($util.getLength(${jdoInfo.getImportedFk()}) > 0) +#foreach($colfk in ${jdoInfo.getImportedFk()}) +#foreach($colfk2 in $colfk) +#if($colfk2.getFkColumnName().equals($col.colName)) +#set ($done= "$fks.add($colfk2.fkName)" ) +#if ($done == "true") +#if ($util.getLength($colfk) > 1) + <many-to-one name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))}"> +#foreach($colfk3 in $colfk) + <column name="$colfk3.getFkColumnName()"/> +#end + </many-to-one> + +#else + <many-to-one name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))}" column="$col.colName"/> + +#end +#end +#set( $done = "true" ) +#end +#end +#end +#end +#if ($done=="false") +#if ($util.getLength($jdoInfo.getPk()) > 1) +#foreach($colpk in ${jdoInfo.getPk()}) +#if ($colpk.col.equals($col.colName)) +#if ($sprimarykeydone=="false") + <composite-id name="id" class="${jdoInfo.javaClassName}\$${jdoInfo.javaClassName}PK"> +#foreach($col in ${jdoInfo.jdoColInfos}) +#foreach($colpk in ${jdoInfo.getPk()}) +#if ($colpk.col.equals($col.colName)) + <key-property name="$col.javaAttName"/> +#end +#end +#end + </composite-id> + +#set( $sprimarykeydone = "true" ) +#end +#set( $done = "true" ) +#end +#end +#end +#end +#if ($done=="false") +#foreach($colpk in ${jdoInfo.getPk()}) +#if ($colpk.col.equals($col.colName)) + <id name="${col.javaAttName}"> +#if (${col.isAutoIncrement()}) + <generator class="native"/> +#end + </id> + +#set( $done = "true" ) +#end +#end +#end +#if ($done=="false") + <property name="${col.javaAttName}" column="$col.colName"/> + +#end +#end +#foreach($colfk in ${jdoInfo.getExportedFk()}) +#set ($fkdone="false") +#if ($util.getLength($colfk) > 1) +#foreach($colfk2 in $colfk) +#if ($fkdone=="false") + <set name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s" inverse="true"> + <key> +#foreach($colfk3 in $colfk) + <column name="$colfk3.getFkColumnName()"/> +#end + </key> + <one-to-many class="$util.DoNameCreator.createDoName($colfk2.getFkTableName())"/> + </set> + +#set ($fkdone="true") +#end +#end +#else +#foreach($colfk2 in $colfk) + <set name="${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getFkTableName()))}s" inverse="true"> + <key column="$colfk2.getFkColumnName()"/> + <one-to-many class="$util.DoNameCreator.createDoName($colfk2.getFkTableName())"/> + </set> + +#end +#end +#end + </class> +</hibernate-mapping> \ No newline at end of file Modified: salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm 2006-10-09 17:55:54 UTC (rev 191) +++ salto-db-generator/trunk/templates/hibernateejb3dao/hibernateutil.vm 2006-10-09 17:56:36 UTC (rev 192) @@ -20,9 +20,11 @@ static { try { - +#if ($annotations=="true") sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); - +#else + sessionFactory = new Configuration().configure().buildSessionFactory(); +#end } catch (Throwable ex) { throw new ExceptionInInitializerError(ex); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-10-09 17:56:23
|
Revision: 191 http://svn.sourceforge.net/salto-db/?rev=191&view=rev Author: rflament Date: 2006-10-09 10:55:54 -0700 (Mon, 09 Oct 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java salto-db-generator/trunk/src/com/salto/db/generator/Constants.java salto-db-generator/trunk/src/com/salto/db/generator/plugin/DefaultAbstractGeneratorPlugin.java salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3Plugin.java salto-db-generator/trunk/src/com/salto/db/generator/plugin/SaltoDbPlugin.java salto-db-generator/trunk/src/plugins.xml Added Paths: ----------- salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3AndHibernateDAOPlugin.java salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernatePlugin.java salto-db-generator/trunk/src/com/salto/db/generator/plugin/PojoHibernateDAOPlugin.java salto-db-generator/trunk/src/com/salto/db/generator/plugin/VelocityAbstractPlugin.java Removed Paths: ------------- salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernateEJB3AndDAOPlugin.java Modified: salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java 2006-10-09 17:55:54 UTC (rev 191) @@ -52,7 +52,8 @@ private static final String DEFAULT_PLUGIN = "Salto-db"; - private static final String GENERATOR_NAME = "Salto-db Ant " + Constants.VERSION; + private static final String GENERATOR_NAME = "Salto-db Generator Ant " + + Constants.VERSION; public void execute() throws BuildException { @@ -68,7 +69,8 @@ try { - ConnectionInfo connectionInfo = new ConnectionInfo(driverClassName, jdbcUrl, login, password, schema); + ConnectionInfo connectionInfo = new ConnectionInfo(driverClassName, + jdbcUrl, login, password, schema); Class.forName(driverClassName); defaultConn = DriverManager.getConnection(jdbcUrl, login, password); @@ -76,14 +78,20 @@ connectionInfo.setConn(defaultConn); log("Successfully connected to database"); - TableInfo[] tableInfos = DatabaseInfo.getTables(defaultConn, null, schema, tableName); - log(tableInfos.length + " table(s) found for table name '" + tableName + "'"); + TableInfo[] tableInfos = DatabaseInfo.getTables(defaultConn, null, + schema, tableName); + log(tableInfos.length + " table(s) found for table name '" + + tableName + "'"); IGeneratorPlugin p = Plugins.getInstance().getPlugin(plugin); if (p == null) { throw new Exception("Cannot find plugin " + plugin); } + log("******************************************"); + log(p.getShortDescription()); + log("******************************************"); + if (prefix == null) { prefix = p.getDefaultPrefix(); } @@ -92,10 +100,12 @@ for (int j = 0; j < tableInfos.length; j++) { - log("Applying plugin '" + tmpl + "' to table '" + tableInfos[j].getTableName() + "'"); + log("Applying plugin '" + tmpl + "' to table '" + + tableInfos[j].getTableName() + "'"); tableInfos[j].setConnInfo(connectionInfo); - TableColInfo[] colInfos = DatabaseInfo.getColumns(tableInfos[j]); + TableColInfo[] colInfos = DatabaseInfo + .getColumns(tableInfos[j]); tableInfos[j].setColInfos(colInfos); jdoInfos[j] = new JdoInfo(tableInfos[j]); @@ -105,7 +115,9 @@ } } - new DataObjectCreate().creerDoSimple(GENERATOR_NAME, prefix, this.getProject().getBaseDir() + "/" + outputDir, packageName, jdoInfos, tmpl); + new DataObjectCreate().creerDoSimple(GENERATOR_NAME, prefix, this + .getProject().getBaseDir() + + "/" + outputDir, packageName, jdoInfos, tmpl); } catch (Exception e) { log(e.getMessage()); throw new BuildException(e); @@ -126,7 +138,8 @@ public void listPlugins() { log("-----------------------------------------"); log("Loaded Plugins : "); - for (Iterator i = Plugins.getInstance().getPlugins().entrySet().iterator(); i.hasNext();) { + for (Iterator i = Plugins.getInstance().getPlugins().entrySet() + .iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); log((String) entry.getKey()); } Modified: salto-db-generator/trunk/src/com/salto/db/generator/Constants.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/Constants.java 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/com/salto/db/generator/Constants.java 2006-10-09 17:55:54 UTC (rev 191) @@ -10,5 +10,5 @@ } - public static final String VERSION = "v1.0.13"; + public static final String VERSION = "v1.0.14"; } Modified: salto-db-generator/trunk/src/com/salto/db/generator/plugin/DefaultAbstractGeneratorPlugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/DefaultAbstractGeneratorPlugin.java 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/DefaultAbstractGeneratorPlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -1,7 +1,9 @@ package com.salto.db.generator.plugin; +import salto.tool.jdo.data.JdoInfo; -public abstract class DefaultAbstractGeneratorPlugin implements IGeneratorPlugin { +public abstract class DefaultAbstractGeneratorPlugin implements + IGeneratorPlugin { protected String generator; @@ -11,18 +13,27 @@ protected String pckName; - - public void init(String generator, String doPrefix, String srcPath, String pckName) throws Exception { + public void init(String generator, String doPrefix, String srcPath, + String pckName) throws Exception { this.generator = generator; this.doPrefix = doPrefix; this.srcPath = srcPath; this.pckName = pckName; - /*this.compName = compName; - this.info = info;*/ + /* + * this.compName = compName; this.info = info; + */ if (this.doPrefix == null) { this.doPrefix = this.getDefaultPrefix(); } } + public void abort() throws Exception { + + } + + public void postExecute(JdoInfo[] infos) throws Exception { + + } + } Copied: salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3AndHibernateDAOPlugin.java (from rev 190, salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernateEJB3AndDAOPlugin.java) =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3AndHibernateDAOPlugin.java (rev 0) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3AndHibernateDAOPlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -0,0 +1,113 @@ +package com.salto.db.generator.plugin; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.apache.velocity.Template; +import org.apache.velocity.app.Velocity; + +import salto.tool.jdo.data.JdoInfo; +import salto.tool.jdo.util.CreatorUtil; + +public class EJB3AndHibernateDAOPlugin extends VelocityAbstractPlugin { + + private EJB3Plugin ejb3Plugin = null; + + private static final String TEMPLATE_PATH = "hibernateejb3dao"; + + public void execute(String className, JdoInfo info) throws Exception { + + ejb3Plugin.execute(className, info); + + CreatorUtil.getDoNameCreator().setPrefix(doPrefix); + Map context = new HashMap(); + context.put("jdoInfo", info); + context.put("util", CreatorUtil.getInstance()); + context.put("templatePath", TEMPLATE_PATH); + context.put("generatorVersion", generator); + context.put("date", new Date()); + info.setJavaPckName(pckName); + info.setJavaClassName(className); + + runVelocity(TEMPLATE_PATH, "hibernatedao.vm", srcPath + "/" + + (pckName + ".hibernate").replace('.', '/') + "/", className + + "HibernateDAO.java", context); + + runVelocity(TEMPLATE_PATH, "dao.vm", srcPath + "/" + + pckName.replace('.', '/') + "/", className + "DAO.java", + context); + + } + + public String getDefaultPrefix() { + return ""; + } + + public String getLongDescription() { + return "This plugin will generate Hibernate EJB3 POJOS, hibernate.cfg.xml and DAOs for each class."; + } + + public String getName() { + return "EJB3AndHibernateDao"; + } + + public String getShortDescription() { + return "EJB3 + Hibernate DAO"; + } + + public void postExecute(JdoInfo[] infos) throws Exception { + + Template t = Velocity.getTemplate(TEMPLATE_PATH + + "/hibernatedaofactory.vm"); + + CreatorUtil.getDoNameCreator().setPrefix(doPrefix); + Map context = new HashMap(); + context.put("jdoInfos", infos); + context.put("connInfo", infos[0].getConnInfo()); + context.put("util", CreatorUtil.getInstance()); + context.put("templatePath", TEMPLATE_PATH); + context.put("generatorVersion", generator); + context.put("date", new Date()); + context.put("dialect", this.ejb3Plugin); + context.put("pckName", pckName); + + runVelocity(TEMPLATE_PATH, "hibernatedaofactory.vm", srcPath + "/" + + (pckName + ".hibernate").replace('.', '/') + "/", + "HibernateDAOFactory.java", context); + + runVelocity(TEMPLATE_PATH, "daofactory.vm", srcPath + "/" + + pckName.replace('.', '/') + "/", "DAOFactory.java", context); + + runVelocity(TEMPLATE_PATH, "abstracthibernatedao.vm", srcPath + "/" + + (pckName + ".hibernate").replace('.', '/') + "/", + "AbstractHibernateDAO.java", context); + + runVelocity(TEMPLATE_PATH, "genericdao.vm", srcPath + "/" + + pckName.replace('.', '/') + "/", "GenericDAO.java", context); + + runVelocity(TEMPLATE_PATH, "hibernateutil.vm", srcPath + "/" + + (pckName + ".hibernate").replace('.', '/') + "/", + "HibernateUtil.java", context); + + runVelocity(TEMPLATE_PATH, "hibernate.cfg.xml.vm", srcPath + "/", + "hibernate.cfg.xml", context); + + } + + public void init(String generator, String doPrefix, String srcPath, + String pckName) throws Exception { + super.init(generator, doPrefix, srcPath, pckName); + ejb3Plugin = new EJB3Plugin(); + ejb3Plugin.init(generator, doPrefix, srcPath, pckName + ".pojo"); + } + + public EJB3Plugin getEjb3Plugin() { + return ejb3Plugin; + } + + public void setEjb3Plugin(EJB3Plugin ejb3Plugin) { + this.ejb3Plugin = ejb3Plugin; + } + +} Modified: salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3Plugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3Plugin.java 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/EJB3Plugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -1,88 +1,55 @@ package com.salto.db.generator.plugin; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; import java.util.Date; -import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; -import java.util.Properties; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; +import java.util.Map; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; - import salto.tool.jdo.data.JdoInfo; import salto.tool.jdo.util.CreatorUtil; -public class EJB3Plugin extends DefaultAbstractGeneratorPlugin { +public class EJB3Plugin extends VelocityAbstractPlugin { private static final String TEMPLATE_PATH = "ejb3"; - public void execute(String className, JdoInfo info) throws Exception { - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileOutputStream fileOutputStream = null; + private boolean generateAnnotations = true; - try { + private static final Map dialects = new HashMap(); - PropertyResourceBundle bundle = (PropertyResourceBundle) ResourceBundle.getBundle("org.apache.velocity.runtime.defaults.velocity"); - Properties props = new Properties(); - Enumeration enumeration = bundle.getKeys(); - String cle; - while (enumeration.hasMoreElements()) { - cle = (String) enumeration.nextElement(); - props.put(cle, bundle.getString(cle)); - } - props.put("resource.loader", "class"); - props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); // - props.put("class.resource.loader.path", TEMPLATE_PATH); - props.put("directive.foreach.counter.initial.value", "0"); - Velocity.init(props); - Template t = Velocity.getTemplate(TEMPLATE_PATH + "/dataobject.vm"); + static { + dialects.put("MySQL", "org.hibernate.dialect.MySQLDialect"); + // TODO: fill this map + } - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - VelocityContext context = new VelocityContext(); - context.put("jdoInfo", info); - context.put("util", CreatorUtil.getInstance()); - context.put("templatePath", TEMPLATE_PATH); - context.put("generatorVersion", generator); - context.put("date", new Date()); - context.put("fks", new HashSet()); - info.setJavaPckName(pckName); - info.setJavaClassName(className); + public static String getDialect(String dbProductName) { + return (String) dialects.get(dbProductName); + } - t.initDocument(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); + public boolean isGenerateAnnotations() { + return generateAnnotations; + } - File dir = new File(srcPath + "/" + pckName.replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + className + ".java"); - fileOutputStream.write(out.toByteArray()); + public void setGenerateAnnotations(boolean generateAnnotations) { + this.generateAnnotations = generateAnnotations; + } - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - out.close(); - } catch (IOException e1) { - } - try { - fileOutputStream.close(); - } catch (IOException e1) { - } - } + public void execute(String className, JdoInfo info) throws Exception { + Map context = new HashMap(); + + CreatorUtil.getDoNameCreator().setPrefix(doPrefix); + context.put("jdoInfo", info); + context.put("util", CreatorUtil.getInstance()); + context.put("templatePath", TEMPLATE_PATH); + context.put("generatorVersion", generator); + context.put("date", new Date()); + context.put("fks", new HashSet()); + context.put("annotations", String.valueOf(generateAnnotations)); + info.setJavaPckName(pckName); + info.setJavaClassName(className); + runVelocity(TEMPLATE_PATH, "dataobject.vm", srcPath + "/" + + pckName.replace('.', '/') + "/", className + ".java", context); + } public String getLongDescription() { @@ -94,18 +61,28 @@ } public String getShortDescription() { - // TODO Auto-generated method stub return "EJB3"; } - public void abort() throws Exception { - // TODO Auto-generated method stub + public void postExecute(JdoInfo[] infos) throws Exception { + if (!generateAnnotations) { - } + CreatorUtil.getDoNameCreator().setPrefix(doPrefix); + Map context = new HashMap(); + context.put("jdoInfos", infos); + context.put("connInfo", infos[0].getConnInfo()); + context.put("util", CreatorUtil.getInstance()); + context.put("templatePath", TEMPLATE_PATH); + context.put("generatorVersion", generator); + context.put("date", new Date()); + context.put("dialect", this); + context.put("pckName", pckName); + context.put("annotations", String.valueOf(generateAnnotations)); - public void postExecute(JdoInfo[] infos) throws Exception { - // TODO Auto-generated method stub + runVelocity(TEMPLATE_PATH, "hibernate.cfg.xml.vm", srcPath, + "hibernate.cfg.xml", context); + } } public String getDefaultPrefix() { Deleted: salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernateEJB3AndDAOPlugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernateEJB3AndDAOPlugin.java 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernateEJB3AndDAOPlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -1,316 +0,0 @@ -package com.salto.db.generator.plugin; - -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; - -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; - -import salto.tool.jdo.data.JdoInfo; -import salto.tool.jdo.util.CreatorUtil; - -public class HibernateEJB3AndDAOPlugin extends DefaultAbstractGeneratorPlugin { - - private EJB3Plugin ejb3Plugin = null; - - private static final String TEMPLATE_PATH = "hibernateejb3dao"; - - private static final Map<String, String> dialects = new HashMap<String, String>(); - - static { - dialects.put("MySQL", "org.hibernate.dialect.MySQLDialect"); - //TODO: fill this map - } - - public static String getDialect(String dbProductName) { - return dialects.get(dbProductName); - } - - public void abort() throws Exception { - // TODO Auto-generated method stub - - } - - public void execute(String className, JdoInfo info) throws Exception { - - ejb3Plugin.execute(className, info); - - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileOutputStream fileOutputStream = null; - - try { - - PropertyResourceBundle bundle = (PropertyResourceBundle) ResourceBundle.getBundle("org.apache.velocity.runtime.defaults.velocity"); - Properties props = new Properties(); - Enumeration enumeration = bundle.getKeys(); - String cle; - while (enumeration.hasMoreElements()) { - cle = (String) enumeration.nextElement(); - props.put(cle, bundle.getString(cle)); - } - props.put("resource.loader", "class"); - props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); // - props.put("class.resource.loader.path", TEMPLATE_PATH); - props.put("directive.foreach.counter.initial.value", "0"); - Velocity.init(props); - Template t = Velocity.getTemplate(TEMPLATE_PATH + "/hibernatedao.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - VelocityContext context = new VelocityContext(); - context.put("jdoInfo", info); - context.put("util", CreatorUtil.getInstance()); - context.put("templatePath", TEMPLATE_PATH); - context.put("generatorVersion", generator); - context.put("date", new Date()); - info.setJavaPckName(pckName); - info.setJavaClassName(className); - - t.initDocument(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - File dir = new File(srcPath + "/" + (pckName + ".hibernate").replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + className + "HibernateDAO.java"); - fileOutputStream.write(out.toByteArray()); - fileOutputStream.close(); - out.close(); - out = new ByteArrayOutputStream(); - - Velocity.init(props); - t = Velocity.getTemplate(TEMPLATE_PATH + "/dao.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - - t.initDocument(); - writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - dir = new File(srcPath + "/" + pckName.replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + className + "DAO.java"); - fileOutputStream.write(out.toByteArray()); - - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - out.close(); - } catch (IOException e1) { - } - try { - fileOutputStream.close(); - } catch (IOException e1) { - } - } - - } - - public String getDefaultPrefix() { - return ""; - } - - public String getLongDescription() { - return "This plugin will generate Hibernate EJB3 POJOS, hibernate.cfg.xml and DAOs for each class."; - } - - public String getName() { - return "HibernateEJB3AndDao"; - } - - public String getShortDescription() { - return "EJB3 + Hibernate DAO"; - } - - public void postExecute(JdoInfo[] infos) throws Exception { - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileOutputStream fileOutputStream = null; - - try { - - PropertyResourceBundle bundle = (PropertyResourceBundle) ResourceBundle.getBundle("org.apache.velocity.runtime.defaults.velocity"); - Properties props = new Properties(); - Enumeration enumeration = bundle.getKeys(); - String cle; - while (enumeration.hasMoreElements()) { - cle = (String) enumeration.nextElement(); - props.put(cle, bundle.getString(cle)); - } - props.put("resource.loader", "class"); - props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); // - props.put("class.resource.loader.path", TEMPLATE_PATH); - props.put("directive.foreach.counter.initial.value", "0"); - Velocity.init(props); - Template t = Velocity.getTemplate(TEMPLATE_PATH + "/hibernatedaofactory.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - VelocityContext context = new VelocityContext(); - context.put("jdoInfos", infos); - context.put("connInfo", infos[0].getConnInfo()); - context.put("util", CreatorUtil.getInstance()); - context.put("templatePath", TEMPLATE_PATH); - context.put("generatorVersion", generator); - context.put("date", new Date()); - context.put("dialect", this); - context.put("pckName", pckName); - - t.initDocument(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - File dir = new File(srcPath + "/" + (pckName + ".hibernate").replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + "HibernateDAOFactory.java"); - fileOutputStream.write(out.toByteArray()); - - out.close(); - out = new ByteArrayOutputStream(); - - Velocity.init(props); - t = Velocity.getTemplate(TEMPLATE_PATH + "/daofactory.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - - t.initDocument(); - writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - dir = new File(srcPath + "/" + pckName.replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + "DAOFactory.java"); - fileOutputStream.write(out.toByteArray()); - out.close(); - out = new ByteArrayOutputStream(); - - Velocity.init(props); - t = Velocity.getTemplate(TEMPLATE_PATH + "/abstracthibernatedao.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - - t.initDocument(); - writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - dir = new File(srcPath + "/" + (pckName + ".hibernate").replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + "AbstractHibernateDAO.java"); - fileOutputStream.write(out.toByteArray()); - out.close(); - out = new ByteArrayOutputStream(); - - Velocity.init(props); - t = Velocity.getTemplate(TEMPLATE_PATH + "/genericdao.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - - t.initDocument(); - writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - dir = new File(srcPath + "/" + pckName.replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + "GenericDAO.java"); - fileOutputStream.write(out.toByteArray()); - - out.close(); - out = new ByteArrayOutputStream(); - - Velocity.init(props); - t = Velocity.getTemplate(TEMPLATE_PATH + "/hibernateutil.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - - t.initDocument(); - writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - dir = new File(srcPath + "/" + (pckName + ".hibernate").replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + "HibernateUtil.java"); - fileOutputStream.write(out.toByteArray()); - out.close(); - out = new ByteArrayOutputStream(); - - Velocity.init(props); - t = Velocity.getTemplate(TEMPLATE_PATH + "/hibernate.cfg.xml.vm"); - - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - - t.initDocument(); - writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - dir = new File(srcPath + "/" + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + "hibernate.cfg.xml"); - fileOutputStream.write(out.toByteArray()); - - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - out.close(); - } catch (IOException e1) { - } - try { - fileOutputStream.close(); - } catch (IOException e1) { - } - } - - } - - public void init(String generator, String doPrefix, String srcPath, String pckName) throws Exception { - super.init(generator, doPrefix, srcPath, pckName); - ejb3Plugin = new EJB3Plugin(); - ejb3Plugin.init(generator, doPrefix, srcPath, pckName + ".pojo"); - } - -} Added: salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernatePlugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernatePlugin.java (rev 0) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/HibernatePlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -0,0 +1,57 @@ +package com.salto.db.generator.plugin; + +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import salto.tool.jdo.data.JdoInfo; +import salto.tool.jdo.util.CreatorUtil; + +public class HibernatePlugin extends EJB3Plugin { + + private static final String TEMPLATE_HIBERNATE = "hibernate"; + + public void execute(String className, JdoInfo info) throws Exception { + super.execute(className, info); + + CreatorUtil.getDoNameCreator().setPrefix(doPrefix); + Map context = new HashMap(); + context.put("jdoInfo", info); + context.put("util", CreatorUtil.getInstance()); + context.put("templatePath", TEMPLATE_HIBERNATE); + context.put("generatorVersion", generator); + context.put("date", new Date()); + context.put("fks", new HashSet()); + context.put("annotations", String.valueOf(false)); + info.setJavaPckName(pckName); + info.setJavaClassName(className); + + runVelocity(TEMPLATE_HIBERNATE, "mapping.hbm.vm", srcPath + "/", + className + ".hbm.xml", context); + + } + + public String getLongDescription() { + return "This plugin will generate pojos from database. Generated class can be used with Hibernate with mapping in xml files."; + } + + public String getName() { + return "Hibernate"; + } + + public String getShortDescription() { + return "Hibernate pojos and xml mapping files."; + } + + public String getDefaultPrefix() { + return ""; + } + + public void init(String generator, String doPrefix, String srcPath, + String pckName) throws Exception { + super.init(generator, doPrefix, srcPath, pckName); + this.setGenerateAnnotations(false); + } + +} Added: salto-db-generator/trunk/src/com/salto/db/generator/plugin/PojoHibernateDAOPlugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/PojoHibernateDAOPlugin.java (rev 0) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/PojoHibernateDAOPlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -0,0 +1,31 @@ +package com.salto.db.generator.plugin; + +import salto.tool.jdo.data.JdoInfo; + +public class PojoHibernateDAOPlugin extends EJB3AndHibernateDAOPlugin { + + public void postExecute(JdoInfo[] infos) throws Exception { + super.postExecute(infos); + this.getEjb3Plugin().postExecute(infos); + } + + public String getLongDescription() { + return "This plugin will generate Hibernate POJOS, hibernate mapping, and DAOs for each class."; + } + + public String getName() { + return "PojoHibernateDao"; + } + + public String getShortDescription() { + return "Pojos + Hibernate mapping + Generic DAO"; + } + + public void init(String generator, String doPrefix, String srcPath, + String pckName) throws Exception { + super.init(generator, doPrefix, srcPath, pckName); + HibernatePlugin hibernatePlugin = new HibernatePlugin(); + hibernatePlugin.init(generator, doPrefix, srcPath, pckName + ".pojo"); + this.setEjb3Plugin(hibernatePlugin); + } +} Modified: salto-db-generator/trunk/src/com/salto/db/generator/plugin/SaltoDbPlugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/SaltoDbPlugin.java 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/SaltoDbPlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -1,151 +1,35 @@ package com.salto.db.generator.plugin; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; import java.util.Date; -import java.util.Enumeration; -import java.util.Properties; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; +import java.util.HashMap; +import java.util.Map; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; - -import salto.tool.ide.IdeException; -import salto.tool.jdo.JdoCreateException; import salto.tool.jdo.data.JdoInfo; import salto.tool.jdo.util.CreatorUtil; -public class SaltoDbPlugin extends DefaultAbstractGeneratorPlugin { +public class SaltoDbPlugin extends VelocityAbstractPlugin { private static final String TEMPLATE_PATH = "saltodb"; public void execute(String className, JdoInfo info) throws Exception { - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileOutputStream fileOutputStream = null; - try { + Map context = new HashMap(); + context.put("jdoInfo", info); + context.put("util", CreatorUtil.getInstance()); + context.put("templatePath", TEMPLATE_PATH); + context.put("generatorVersion", generator); + context.put("date", new Date()); + info.setJavaPckName(pckName); + info.setJavaClassName(className); - PropertyResourceBundle bundle = (PropertyResourceBundle) ResourceBundle.getBundle("org.apache.velocity.runtime.defaults.velocity"); - Properties props = new Properties(); - Enumeration enumeration = bundle.getKeys(); - String cle; - while (enumeration.hasMoreElements()) { - cle = (String) enumeration.nextElement(); - props.put(cle, bundle.getString(cle)); - } - props.put("resource.loader", "class"); - props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); // - props.put("class.resource.loader.path", TEMPLATE_PATH); - props.put("directive.foreach.counter.initial.value", "0"); - Velocity.init(props); - Template t = Velocity.getTemplate(TEMPLATE_PATH + "/dataobject.vm"); + runVelocity(TEMPLATE_PATH, "dataobject.vm", srcPath + "/" + + pckName.replace('.', '/') + "/", className + ".java", context); - CreatorUtil.getDoNameCreator().setPrefix(doPrefix); - VelocityContext context = new VelocityContext(); - context.put("jdoInfo", info); - context.put("util", CreatorUtil.getInstance()); - context.put("templatePath", TEMPLATE_PATH); - context.put("generatorVersion", generator); - context.put("date", new Date()); - info.setJavaPckName(pckName); - info.setJavaClassName(className); - - t.initDocument(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - - File dir = new File(srcPath + "/" + pckName.replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + className + ".java"); - fileOutputStream.write(out.toByteArray()); - - creerDescription(generator, srcPath, pckName, className, info, TEMPLATE_PATH); - - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - out.close(); - } catch (IOException e1) { - } - try { - fileOutputStream.close(); - } catch (IOException e1) { - } - } - + runVelocity(TEMPLATE_PATH, "desc/description.vm", srcPath + "/" + + pckName.replace('.', '/') + "/", className + "Desc.java", + context); } - private void creerDescription(String generator, String srcPath, String pckName, String compName, JdoInfo info, String templatePath) throws JdoCreateException, IdeException { - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileOutputStream fileOutputStream = null; - try { - /* - * r�cup�ration de la template de génération - */ - PropertyResourceBundle bundle = (PropertyResourceBundle) ResourceBundle.getBundle("org.apache.velocity.runtime.defaults.velocity"); - Properties props = new Properties(); - Enumeration enumeration = bundle.getKeys(); - String cle; - while (enumeration.hasMoreElements()) { - cle = (String) enumeration.nextElement(); - props.put(cle, bundle.getString(cle)); - } - props.put("resource.loader", "class"); - props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - props.put("directive.foreach.counter.initial.value", "0"); - Velocity.init(props); - Template t = Velocity.getTemplate(templatePath + "/desc/description.vm"); - /* - * mise � jour du context - */ - VelocityContext context = new VelocityContext(); - context.put("jdoInfo", info); - context.put("util", CreatorUtil.getInstance()); - context.put("templatePath", templatePath); - context.put("generatorVersion", generator); - context.put("date", new Date()); - info.setJavaPckName(pckName); - info.setJavaClassName(compName); - - t.initDocument(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); - t.merge(context, writer); - writer.flush(); - // importation des sources - File dir = new File(srcPath + "/" + pckName.replace('.', '/') + "/"); - try { - dir.mkdirs(); - } catch (Exception e) { - } - fileOutputStream = new FileOutputStream(dir.getPath() + "/" + compName + "Desc.java"); - fileOutputStream.write(out.toByteArray()); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - out.close(); - } catch (IOException e1) { - } - try { - fileOutputStream.close(); - } catch (IOException e1) { - } - } - } - public String getLongDescription() { return "This plugin will generate Salto-db DataObjects."; } @@ -158,16 +42,6 @@ return "Salto-db Dataobjects"; } - public void abort() throws Exception { - // TODO Auto-generated method stub - - } - - public void postExecute(JdoInfo[] infos) throws Exception { - // TODO Auto-generated method stub - - } - public String getDefaultPrefix() { return "Do"; } Added: salto-db-generator/trunk/src/com/salto/db/generator/plugin/VelocityAbstractPlugin.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/plugin/VelocityAbstractPlugin.java (rev 0) +++ salto-db-generator/trunk/src/com/salto/db/generator/plugin/VelocityAbstractPlugin.java 2006-10-09 17:55:54 UTC (rev 191) @@ -0,0 +1,84 @@ +package com.salto.db.generator.plugin; + +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; + +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; + +public abstract class VelocityAbstractPlugin extends + DefaultAbstractGeneratorPlugin { + + protected static void runVelocity(String templatesPath, + String templateName, String outputDirectory, String outputFilename, + Map context) throws Exception { + // Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileOutputStream fileOutputStream = null; + + try { + + PropertyResourceBundle bundle = (PropertyResourceBundle) ResourceBundle + .getBundle("org.apache.velocity.runtime.defaults.velocity"); + Properties props = new Properties(); + Enumeration enumeration = bundle.getKeys(); + String cle; + while (enumeration.hasMoreElements()) { + cle = (String) enumeration.nextElement(); + props.put(cle, bundle.getString(cle)); + } + props.put("resource.loader", "class"); + props + .put("class.resource.loader.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + props.put("class.resource.loader.path", templatesPath); + props.put("directive.foreach.counter.initial.value", "0"); + Velocity.init(props); + Template t = Velocity.getTemplate(templatesPath + "/" + + templateName); + + VelocityContext velocityContext = new VelocityContext(); + for (Iterator iterator = context.entrySet().iterator(); iterator + .hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + velocityContext.put((String) entry.getKey(), entry.getValue()); + } + + t.initDocument(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + out)); + t.merge(velocityContext, writer); + writer.flush(); + File dir = new File(outputDirectory); + dir.mkdirs(); + fileOutputStream = new FileOutputStream(dir.getPath() + "/" + + outputFilename); + fileOutputStream.write(out.toByteArray()); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + out.close(); + } catch (IOException e1) { + } + try { + fileOutputStream.close(); + } catch (IOException e1) { + } + } + + } + +} Modified: salto-db-generator/trunk/src/plugins.xml =================================================================== --- salto-db-generator/trunk/src/plugins.xml 2006-09-28 20:44:40 UTC (rev 190) +++ salto-db-generator/trunk/src/plugins.xml 2006-10-09 17:55:54 UTC (rev 191) @@ -2,6 +2,8 @@ <plugins> <plugin class="com.salto.db.generator.plugin.SaltoDbPlugin" /> - <plugin class="com.salto.db.generator.plugin.EJB3Plugin" /> - <plugin class="com.salto.db.generator.plugin.HibernateEJB3AndDAOPlugin" /> + <plugin class="com.salto.db.generator.plugin.EJB3Plugin" /> + <plugin class="com.salto.db.generator.plugin.HibernatePlugin" /> + <plugin class="com.salto.db.generator.plugin.EJB3AndHibernateDAOPlugin" /> + <plugin class="com.salto.db.generator.plugin.PojoHibernateDAOPlugin" /> </plugins> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:44:46
|
Revision: 190 http://svn.sourceforge.net/salto-db/?rev=190&view=rev Author: rflament Date: 2006-09-28 13:44:40 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Added Paths: ----------- salto-db-generator-eclipse/tags/v1_0_13/ Copied: salto-db-generator-eclipse/tags/v1_0_13 (from rev 189, salto-db-generator-eclipse/trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:40:40
|
Revision: 189 http://svn.sourceforge.net/salto-db/?rev=189&view=rev Author: rflament Date: 2006-09-28 13:40:32 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator-eclipse/trunk/META-INF/MANIFEST.MF Modified: salto-db-generator-eclipse/trunk/META-INF/MANIFEST.MF =================================================================== --- salto-db-generator-eclipse/trunk/META-INF/MANIFEST.MF 2006-09-28 20:35:38 UTC (rev 188) +++ salto-db-generator-eclipse/trunk/META-INF/MANIFEST.MF 2006-09-28 20:40:32 UTC (rev 189) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Salto-db Generator Eclipse Plug-in Bundle-SymbolicName: com.salto.db.generator.eclipse;singleton:=true -Bundle-Version: 1.0.12 +Bundle-Version: 1.0.13 Bundle-Activator: com.salto.db.generator.eclipse.Activator Bundle-Vendor: Salto Consulting Bundle-Localization: plugin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:35:43
|
Revision: 188 http://svn.sourceforge.net/salto-db/?rev=188&view=rev Author: rflament Date: 2006-09-28 13:35:38 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Property Changed: ---------------- salto-db-generator-eclipse/trunk/lib/salto-db-generator.jar Property changes on: salto-db-generator-eclipse/trunk/lib/salto-db-generator.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:34:16
|
Revision: 186 http://svn.sourceforge.net/salto-db/?rev=186&view=rev Author: rflament Date: 2006-09-28 13:34:10 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Added Paths: ----------- salto-db-generator/tags/v1_0_13/ Copied: salto-db-generator/tags/v1_0_13 (from rev 185, salto-db-generator/trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:33:09
|
Revision: 185 http://svn.sourceforge.net/salto-db/?rev=185&view=rev Author: rflament Date: 2006-09-28 13:33:03 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/salto-db-generator.jar Modified: salto-db-generator/trunk/salto-db-generator.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:32:22
|
Revision: 184 http://svn.sourceforge.net/salto-db/?rev=184&view=rev Author: rflament Date: 2006-09-28 13:32:12 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java Added Paths: ----------- salto-db-generator/trunk/src/com/salto/db/generator/Constants.java Modified: salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java 2006-09-28 20:31:31 UTC (rev 183) +++ salto-db-generator/trunk/src/com/salto/db/ant/DOGeneratorTask.java 2006-09-28 20:32:12 UTC (rev 184) @@ -16,6 +16,7 @@ import salto.tool.sql.data.TableColInfo; import salto.tool.sql.data.TableInfo; +import com.salto.db.generator.Constants; import com.salto.db.generator.plugin.IGeneratorPlugin; import com.salto.db.generator.plugin.Plugins; @@ -51,7 +52,7 @@ private static final String DEFAULT_PLUGIN = "Salto-db"; - private static final String GENERATOR_NAME = "Salto-db Ant v1.0.11"; + private static final String GENERATOR_NAME = "Salto-db Ant " + Constants.VERSION; public void execute() throws BuildException { Added: salto-db-generator/trunk/src/com/salto/db/generator/Constants.java =================================================================== --- salto-db-generator/trunk/src/com/salto/db/generator/Constants.java (rev 0) +++ salto-db-generator/trunk/src/com/salto/db/generator/Constants.java 2006-09-28 20:32:12 UTC (rev 184) @@ -0,0 +1,14 @@ +package com.salto.db.generator; + +/** + * @author rfl...@la... + * + */ +public final class Constants { + + private Constants() { + + } + + public static final String VERSION = "v1.0.13"; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rfl...@us...> - 2006-09-28 20:31:45
|
Revision: 183 http://svn.sourceforge.net/salto-db/?rev=183&view=rev Author: rflament Date: 2006-09-28 13:31:31 -0700 (Thu, 28 Sep 2006) Log Message: ----------- Modified Paths: -------------- salto-db-generator/trunk/templates/ejb3/setter.vm salto-db-generator/trunk/templates/ejb3/variable.vm salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm Removed Paths: ------------- salto-db-generator/trunk/templates/ejb3/TODO Deleted: salto-db-generator/trunk/templates/ejb3/TODO =================================================================== --- salto-db-generator/trunk/templates/ejb3/TODO 2006-09-26 19:01:46 UTC (rev 182) +++ salto-db-generator/trunk/templates/ejb3/TODO 2006-09-28 20:31:31 UTC (rev 183) @@ -1,2 +0,0 @@ -manyToMany + jointables -when a foreign key is also primary key it's not well handled \ No newline at end of file Modified: salto-db-generator/trunk/templates/ejb3/setter.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/setter.vm 2006-09-26 19:01:46 UTC (rev 182) +++ salto-db-generator/trunk/templates/ejb3/setter.vm 2006-09-28 20:31:31 UTC (rev 183) @@ -37,12 +37,12 @@ this.${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))} = ${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))}; } +#end #set( $done = "true" ) #end #end #end #end -#end #if ($done=="false") #if ($util.getLength($jdoInfo.getPk()) > 1) #foreach($colpk in ${jdoInfo.getPk()}) Modified: salto-db-generator/trunk/templates/ejb3/variable.vm =================================================================== --- salto-db-generator/trunk/templates/ejb3/variable.vm 2006-09-26 19:01:46 UTC (rev 182) +++ salto-db-generator/trunk/templates/ejb3/variable.vm 2006-09-28 20:31:31 UTC (rev 183) @@ -12,12 +12,12 @@ */ private $util.DoNameCreator.createDoName($colfk2.getPkTableName()) ${util.DoNameCreator.class2attribute($util.DoNameCreator.createDoName($colfk2.getPkTableName()))}; +#end #set( $done = "true" ) #end #end #end #end -#end #if ($done=="false") #if ($util.getLength($jdoInfo.getPk()) > 1) #foreach($colpk in ${jdoInfo.getPk()}) Modified: salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm 2006-09-26 19:01:46 UTC (rev 182) +++ salto-db-generator/trunk/templates/hibernateejb3dao/dao.vm 2006-09-28 20:31:31 UTC (rev 183) @@ -37,7 +37,7 @@ /** * Find ${jdoInfo.javaClassName} by ${col.javaAttName} */ - public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.javaAttClass ${col.javaAttName}); + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}); #end #else @@ -52,7 +52,7 @@ /** * Find ${jdoInfo.javaClassName} by ${col.javaAttName} */ - public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.javaAttClass ${col.javaAttName}); + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}); #end #end Modified: salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm =================================================================== --- salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm 2006-09-26 19:01:46 UTC (rev 182) +++ salto-db-generator/trunk/templates/hibernateejb3dao/hibernatedao.vm 2006-09-28 20:31:31 UTC (rev 183) @@ -58,19 +58,59 @@ #if ($util.getLength($jdoInfo.getPk()) > 1) #foreach($col in ${jdoInfo.jdoColInfos}) +#set ($ispk="false") +#foreach($colpk in ${jdoInfo.getPk()}) +#if ($colpk.col.equals($col.colName)) +#set ($ispk="true") +#end +#end +#set ($isfk="false") +#foreach($colfk in ${jdoInfo.getImportedFk()}) +#foreach($colfk2 in $colfk) +#if($colfk2.getFkColumnName().equals($col.colName)) +#set ($isfk="true") /** * Find ${jdoInfo.javaClassName} by ${col.javaAttName} */ @SuppressWarnings("unchecked") - public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.javaAttClass ${col.javaAttName}) { - Query q = session.createQuery("from ${jdoInfo.javaClassName} where ${col.javaAttName} = :${col.javaAttName}"); + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}) { + Query q = session.createQuery("from ${jdoInfo.javaClassName} where $util.doNameCreator.class2attribute($util.doNameCreator.createDoName(${colfk2.getPkTableName()})).${colfk2.getPkColumnName()} = :${col.javaAttName}"); q.setParameter("${col.javaAttName}",${col.javaAttName}); q.setCacheable(true); return q.list(); } #end +#end +#end +#if ($isfk=="false" && $ispk=="false") + /** + * Find ${jdoInfo.javaClassName} by ${col.javaAttName} + */ + @SuppressWarnings("unchecked") + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}) { + Query q = session.createQuery("from ${jdoInfo.javaClassName} where ${col.javaAttName} = :${col.javaAttName}"); + q.setParameter("${col.javaAttName}",${col.javaAttName}); + q.setCacheable(true); + return q.list(); + } + #else +#if ($ispk=="true") + /** + * Find ${jdoInfo.javaClassName} by ${col.javaAttName} + */ + @SuppressWarnings("unchecked") + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}) { + Query q = session.createQuery("from ${jdoInfo.javaClassName} where id.${col.javaAttName} = :${col.javaAttName}"); + q.setParameter("${col.javaAttName}",${col.javaAttName}); + q.setCacheable(true); + return q.list(); + } +#end +#end +#end +#else #foreach($col in ${jdoInfo.jdoColInfos}) #set ($ispk="false") #foreach($colpk in ${jdoInfo.getPk()}) @@ -87,12 +127,13 @@ * Find ${jdoInfo.javaClassName} by ${col.javaAttName} */ @SuppressWarnings("unchecked") - public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.javaAttClass ${col.javaAttName}) { + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}) { Query q = session.createQuery("from ${jdoInfo.javaClassName} where $util.doNameCreator.class2attribute($util.doNameCreator.createDoName(${colfk2.getPkTableName()})).${colfk2.getPkColumnName()} = :${col.javaAttName}"); q.setParameter("${col.javaAttName}",${col.javaAttName}); q.setCacheable(true); return q.list(); } + #end #end #end @@ -101,12 +142,13 @@ * Find ${jdoInfo.javaClassName} by ${col.javaAttName} */ @SuppressWarnings("unchecked") - public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.javaAttClass ${col.javaAttName}) { + public List<${jdoInfo.javaClassName}> findBy$util.doNameCreator.attribute2class($col.javaAttName)($col.getNonPrimitifClass() ${col.javaAttName}) { Query q = session.createQuery("from ${jdoInfo.javaClassName} where ${col.javaAttName} = :${col.javaAttName}"); q.setParameter("${col.javaAttName}",${col.javaAttName}); q.setCacheable(true); return q.list(); } + #end #end #end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From:
<ji...@is...> - 2006-09-26 08:36:47
|
DAO should have a removeById() method ------------------------------------- Key: SALTODB-4 URL: http://issues.salto-consulting.com/jira/browse/SALTOD= B-4 Project: Salto-db Issue Type: Improvement Components: Salto-db Generator Reporter: R=C3=A9mi Flament Assigned To: R=C3=A9mi Flament When you want to remove an entity with the generated EJB3 DAO, you need to = load it from database with the getById() method and then to remove it with = the delete() method.=20 =20 This makes two sql orders, while it could be done with only one. The DAO s= hould have a generated removeById() method to do this. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://issues.salto-consulting.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From:
<ji...@is...> - 2006-09-25 16:07:00
|
Some generated findByXXX() methods doesn't work=20 ------------------------------------------------ Key: SALTODB-3 URL: http://issues.salto-consulting.com/jira/browse/SALTOD= B-3 Project: Salto-db Issue Type: Bug Components: Salto-db Generator Reporter: R=C3=A9mi Flament Assigned To: R=C3=A9mi Flament The generated findByXXX() method doesn't work if XXX is a part of a foreign= key.=20 The generated HQL is not good, because it relies on the attribute which sho= uld have the same name as the SQL column name, except that this attribute i= s not generated, since it is a part of a foreign key, it's a pointer to ano= ther object. Bad HQL : "where idXXX =3D :idXXX" Good HQL : "where XXX.id =3D :idXXX" --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://issues.salto-consulting.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <ji...@is...> - 2006-09-13 08:09:36
|
This is a test message from JIRA. Server: Default SMTP Server SMTP Port: 25 Description: From: ji...@is... Host User Name: null |
From: <ji...@is...> - 2006-09-13 08:07:11
|
This is a test message from JIRA. Server: Default SMTP Server SMTP Port: 25 Description: From: ji...@is... Host User Name: null |