## ============================================================================ ## Filename : Hbm2JavaBeanTemplate.vm ## Note(s) : This template is used to generate a Java Bean class based on ## a database table/view for use with Hibernate 2.0. ## ## Copyright (c) 2008 ThinkUI Software Inc. All rights reserved. ## ============================================================================ ## ## **************************************************************************** ## The following variables are available in this template. For more ## information on any of the following variable, please refer to the user guide. ## **************************************************************************** ## $projectName ## $authorName ## $headerText ## $tableName ## $schemaName ## $className ## $packageName ## $prjPkgName ## $prjClassPrefix ## $dataClass ## $superClassName ## $date ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import java.io.Serializable; import java.math.BigInteger; import java.sql.Timestamp; import java.sql.Date; #if ( $lifecycleStubs ) import net.sf.hibernate.CallbackException; import net.sf.hibernate.Lifecycle; import net.sf.hibernate.Session; #end /** * Implements the ${className} Java Bean for use with Hibernate 2.0. */ public class ${className} extends ${superClassName} implements Serializable#if ($lifecycleStubs), Lifecycle#end { // // Attributes. // #foreach( $attr in $dataClass.getAttributes() ) private $codeGen.getAttributeTypeValueClassName($attr.getType()) $codeGen.toVarName($attr.getName());#if ($attr.isRequired()) // required;#end #end /** * ${className} constructor. */ public ${className}() { super(); } // // Access methods. // #foreach( $attr in $dataClass.getAttributes() ) /** * @return the $attr.getCaption(). */ public final $codeGen.getAttributeTypeValueClassName($attr.getType()) get${codeGen.toTypeName($attr.getName())}() { return $codeGen.toVarName($attr.getName()); } /** * Sets the $attr.getCaption(). */ public final void set${codeGen.toTypeName($attr.getName())}($codeGen.getAttributeTypeValueClassName($attr.getType()) $codeGen.toVarName($attr.getName())) { this.$codeGen.toVarName($attr.getName()) = $codeGen.toVarName($attr.getName()); } #end public final String toString() { StringBuffer sb = new StringBuffer("${className}{"); #set( $firstItem = 1 ) #foreach( $attr in $dataClass.getAttributes() ) #if ($firstItem == 1) #set( $firstItem = 0 ) #else sb.append(", ");#end sb.append("${attr.getName()}=");sb.append(get${codeGen.toTypeName($attr.getName())}()); #end sb.append("}"); return sb.toString(); } #if ( $lifecycleStubs ) /** * Called by Hibernate framework just before the object is saved in the database. */ public boolean onSave(Session session) throws CallbackException { // TODO - Need to update generate Hibernate Lifecycle onSave() method stub. return NO_VETO; } /** * Called by Hibernate framework just before the object is updated in the database */ public final boolean onUpdate(Session session) throws CallbackException { // TODO - Need to update generate Hibernate Lifecycle onUpdate() method stub. return NO_VETO; } /** * Called by Hibernate framework just before the object is delete in the database */ public final boolean onDelete(Session session) throws CallbackException { // TODO - Need to update generate Hibernate Lifecycle onDelete() method stub. return NO_VETO; } /** * Called by Hibernate framework just after the object is loaded from the database */ public void onLoad(Session session, Serializable id) { // TODO - Need to update generate Hibernate Lifecycle onLoad() method stub. } #end }