[hibernate-issues] [Hibernate-JIRA] Updated: (HBX-945) CLONE -hbm2java does not generate correct POJO property types for UserType columns

Jim Elliott (JIRA) noreply at atlassian.com
Tue Jul 3 00:03:52 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-945?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jim Elliott updated HBX-945:
----------------------------

    Attachment: TestCase.zip

To see the problem, expand the test case archive, and execute "ant codegen" from within its top-level directory.

This will create, among other things, the file:
src/com/oreilly/hh/data/Track.java (based on the mapping file src/com/oreilly/hh/data/Track.hbm.xml).

In Track.java, the sourceMedia property should have the type com.oreilly.hh.SourceMedia, but instead gets the type com.oreilly.hh.SourceMediaType (the UserType that handles its mapping).

Similarly, the volume property should have the type com.oreilly.hh.StereoVolume, but instead gets the type com.oreilly.hh.StereoVolumeType.

If it is any help, this problem did *not* occur when we were trying to use the Hibernate tools (3.2.0.beta9a) having directly downloaded them and expanded them into the lib directory. The problem occurs, however, when trying to use the Maven Ant Tasks to automatically obtain them as dependencies.

> CLONE -hbm2java does not generate correct POJO property types for UserType columns
> ----------------------------------------------------------------------------------
>
>                 Key: HBX-945
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-945
>             Project: Hibernate Tools
>          Issue Type: Bug
>          Components: hbm2java
>    Affects Versions: 3.1alpha5
>         Environment: Pulled from CVS somewhere between 3.1a5 and 3.1b1
>            Reporter: Brill Pappin
>             Fix For: 3.1beta2
>
>         Attachments: TestCase.zip
>
>
> I have defined my own custom UserType (which coincidentally maps a DB2 decimal field to a java.sql.Date property, using some special formatting...).
> My mapping file contains:
>         <property name="connectDate" type="DecimalDateType">
>             <column name="UMPCN" precision="8" scale="0" not-null="true" />
>         </property>
> where DecimalDateType is the fully-qualified name of my UserType class.
> The POJO generated contains the property:
>         private DecimalDateType connectDate;
> This is incorrect. It SHOULD have generated a property of the type returned by DecimalDateType.returnedClass() (which in this case is java.sql.Date.class). ie. It should have been
>         private java.sql.Date connectDate;
> The "decision" of which type to generate (ie where the error manifests itself) error appears to be in
>         Cfg2JavaTool.java
> in the method
>         private String getJavaTypeName(Value value, boolean preferRawTypeNames) 
> I am not sure of the exact fix, since there appear to be other checks being done, and I do not understand all the logic here.
> Thanks! 
> james

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