Announcement Announcement Module
Collapse
No announcement yet.
some way to resolve this with ant or other tool Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • some way to resolve this with ant or other tool

    hello guys

    i am in hell with this
    i work with xdoclet and pls see this situtation
    Code:
    /**
      * @hibernate.property column="precioUnitarioVenta" length="6" not-null="true"                                           
     */
    public BigDecimal getPrecioUnitarioVenta() {
    	return precioUnitarioVenta;
    }
    if i go to my mapping file i see this
    Code:
       <property
                name="precioUnitarioVenta"
                type="java.math.BigDecimal"
                update="true"
                insert="true"
                column="precioUnitarioVenta"
                length="6" 
                not-null="true"
            />
    it seems fine,
    but if i see the type of each column of the table in the db
    i see this
    decimal(19,2)

    here
    http://www.hibernate.org/hib_docs/v3...ation-property

    i can see this
    Code:
    <property
            name="propertyName"                                          (1)
            column="column_name"                                         (2)
            type="typename"                                              (3)
            update="true|false"                                          (4)
            insert="true|false"                                          (4)
            formula="arbitrary SQL expression"                           (5)
            access="field|property|ClassName"                            (6)
            lazy="true|false"                                            (7)
            unique="true|false"                                          (8)
            not-null="true|false"                                        (9)
            optimistic-lock="true|false"                                 (10)
            generated="never|insert|always"                              (11)
            node="element-name|@attribute-name|element/@attribute|."
            index="index_name"
            unique_key="unique_key_id"
            length="L"
            precision="P"
            scale="S" 
    />
    bold part sadly are not supported by xdoclet 1
    and if in my java code i write anyway this

    Code:
    /**
    * @hibernate.property not-null="true"
    * 				precision="9"
    *   				scale="2" 
    *   				column="precioUnitario"
    * 					                                              
    */
    public BigDecimal getPrecioUnitario() {
    	return precioUnitario;
    }
    public void setPrecioUnitario(BigDecimal precioUnitario) {
    	this.precioUnitario = precioUnitario;
    }
    with the ant task i dont recieve any error but , in the mapping file appear

    Code:
     <property
                name="precioUnitario"
                type="java.math.BigDecimal"
                update="true"
                insert="true"
                column="precioUnitario"
                not-null="true"
            />
    of course length value was not written with xdoclet but the desired properties not appear
    precision,scale

    exists a way with ant after to create the mapping files (hbm.xml)
    replace
    Code:
     <property
                name="precioUnitario"
                type="java.math.BigDecimal"
                update="true"
                insert="true"
                column="precioUnitario"
                not-null="true"
            />
    by

    Code:
     <property
                name="precioUnitario"
                type="java.math.BigDecimal"
                precision="9"
    	    scale="2" 
                update="true"
                insert="true"
                column="precioUnitario"
                not-null="true"
            />
    just how work with a txt document,
    i can do this manually maybe for one property but for 500 properties i see this a suicide

    exists a way to do this approcach with ant or other tool?

    thanks in advanced

  • #2
    Change the code generator, not the generated code. This means touching XDoclet somewhere. But change it only once, not 500 times.

    Joerg

    Comment


    • #3
      hi Jorg

      ant has a useful way
      Code:
      <target name="seek" >
      	<replace dir="${bindir}/com/appname/modelo/entidades/">
      		 <include name="**/*.xml"/>
      		   <replacetoken><![CDATA[type="java.math.BigDecimal"]]></replacetoken>
      		   <replacevalue><![CDATA[type="java.math.BigDecimal"
                                                        precision="9"
                                                        scale="2"]]>
                         </replacevalue>
      	</replace>
      </target>
      maybe can help for other users

      thanks anyway for your suggestion

      regards

      Comment


      • #4
        If you consider this a solution ...

        One of Ant's replacing tools (there were two ways to do things like that) is broken regarding encoding issues.

        Joerg

        Comment


        • #5
          If you consider this a solution ...
          why did you say that?

          (there were two ways to do things like that) is broken regarding encoding issues.
          i never heard about that

          tell me, how you create your mapping files? with xdoclet2?

          regards

          Comment


          • #6
            Originally posted by dr_pompeii View Post
            why did you say that?
            Because it's my opinion. You should fix the issue, not the symptom. As I said in my first post: Fix the generator, not the generated code.

            Originally posted by dr_pompeii View Post
            i never heard about that
            When I once looked into replacing placeholders with Ant I found two ways to do it. The second one was <copy> with filtering. I only looked it up and the manual contains now a hint on the encoding issue. At that time the second solution worked. I don't remember if it was <replace>.

            Originally posted by dr_pompeii View Post
            tell me, how you create your mapping files? with xdoclet2?
            We used XDoclet once for a J2EE project but that's a while (5 years?) ago. At the moment I'm not involved in any project generating the mapping files but we write them by hand. One of the project generates the beans from the mapping files (so it works the other way around).

            Joerg

            Comment

            Working...
            X