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. |