[hibernate-issues] [Hibernate-JIRA] Closed: (HBX-664) Patch to allow reverse engineering to work with tables and associations ending with "s"

Max Rydahl Andersen (JIRA) noreply at atlassian.com
Thu Sep 14 13:25:25 EDT 2006


     [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-664?page=all ]
     
Max Rydahl Andersen closed HBX-664:
-----------------------------------

    Resolution: Duplicate

there is a issue reporting the error elsewhere.

thank you for the patch, but it does not solve the problem completly since
it still assumes what the actual "other side" is instead of locating it and use its proper name.

> Patch to allow reverse engineering to work with tables and associations ending with "s" 
> ----------------------------------------------------------------------------------------
>
>          Key: HBX-664
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-664
>      Project: Hibernate Tools
>         Type: Patch

>   Components: reverse-engineer
>     Versions: 3.1.beta5
>     Reporter: Jarkko Lietolahti

>
>
> Index: java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
> ===================================================================
> --- java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java	(revision 9925)
> +++ java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java	(working copy)
> @@ -86,6 +86,10 @@
>  		return StringHelper.unqualify(getMappedClassName());
>  	}
>  	
> +	public String getShortNamePlural() {
> +		return ReverseEngineeringStrategyUtil.simplePluralize(getShortName());
> +	}
> +	
>  	public String getQualifiedDeclarationName() {
>  		String generatedName = getMetaAsString( MetaAttributeConstants.GENERATED_CLASS );
>  		if ( generatedName == null || generatedName.trim().length() == 0 ) {
> Index: java/org/hibernate/tool/hbm2x/pojo/POJOClass.java
> ===================================================================
> --- java/org/hibernate/tool/hbm2x/pojo/POJOClass.java	(revision 9925)
> +++ java/org/hibernate/tool/hbm2x/pojo/POJOClass.java	(working copy)
> @@ -74,7 +74,8 @@
>  
>  	public String getPackageName();
>  	public String getShortName();
> -
> +	public String getShortNamePlural();
> +	
>  	public Iterator getToStringPropertiesIterator();
>  	public Iterator getEqualsHashCodePropertiesIterator();
>  	
> Index: templates/seam/editorbean.java.ftl
> ===================================================================
> --- templates/seam/editorbean.java.ftl	(revision 9925)
> +++ templates/seam/editorbean.java.ftl	(working copy)
> @@ -1,5 +1,5 @@
>  ${pojo.getPackageDeclaration()}
> -// Generated ${date} by Hibernate Tools ${version}
> +// Generated ${date} by Hibernate Tools ${version}-jab
>  
>  <#assign classbody>
>  <#assign entityEditor = pojo.shortName.toLowerCase() + "Editor"><#assign entityFinder = pojo.shortName.toLowerCase() + "Finder"><#assign entityList = pojo.shortName.toLowerCase() + "List"><#assign entity = pojo.shortName.toLowerCase()><#assign entityClass = pojo.importType(pojo.qualifiedDeclarationName)>
> @@ -38,7 +38,7 @@
>      @${pojo.importType("org.jboss.seam.annotations.In")}(required=false)
>      private transient ${pojo.shortName}Finder ${entityFinder};
>  
> -    @${pojo.importType("org.jboss.seam.annotations.In")}
> +    @${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
>      private transient ${pojo.importType("java.util.ResourceBundle")} resourceBundle;
>      
>      @${pojo.importType("org.jboss.seam.annotations.Begin")}(join=true)
> @@ -57,7 +57,7 @@
>  </#if>       entityManager.persist(instance);
>         isNew = false;
>  <#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isManyToOne(property)><#assign getter = "get" + pojo.getPropertyName(property)>       if (instance.${getter}()!=null) {
> -          instance.${getter}().get${pojo.shortName}s().add(instance);
> +        	instance.${getter}().get${pojo.shortNamePlural}().add(instance);
>         }
>  </#if></#foreach>       refreshFinder();
>         return "edit${pojo.shortName}";
> @@ -72,7 +72,8 @@
>      @${pojo.importType("org.jboss.seam.annotations.End")}(ifOutcome="find")
>      public String delete() {
>         entityManager.remove(instance);
> -<#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isManyToOne(property)><#assign getter = "get" + pojo.getPropertyName(property)>       instance.${getter}().get${pojo.shortName}s().remove(instance);
> +<#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isManyToOne(property)><#assign getter = "get" + pojo.getPropertyName(property)>      
> + instance.${getter}().get${pojo.shortNamePlural}().remove(instance);
>  </#if></#foreach>       refreshFinder();
>         return doneOutcome;
>      }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list