[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4347) use property names defined in CompositeUserType as default column names

Steve Ebersole (JIRA) noreply at atlassian.com
Mon Mar 5 18:19:48 EST 2012


     [ https://hibernate.onjira.com/browse/HHH-4347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole updated HHH-4347:
--------------------------------

    Pull Requests: https://github.com/hibernate/hibernate-orm/pull/11
    Fix Version/s: 5.0.0

Targetting this for 5.0 because as I mentioned in my last comment, I am worried about column names that end up exceeding the identifier length limits for the particular dialect.  Because the commonality (path) is all prefixed, simply truncating an applying suffix is counter-productive.

> use property names defined in CompositeUserType as default column names
> -----------------------------------------------------------------------
>
>                 Key: HHH-4347
>                 URL: https://hibernate.onjira.com/browse/HHH-4347
>             Project: Hibernate ORM
>          Issue Type: New Feature
>          Components: annotations
>            Reporter: Michael Newcomb
>            Priority: Minor
>             Fix For: 5.0.0
>
>         Attachments: HH-4347-hibernate-core.patch, HH-4347-hibernate-testsuite.patch
>
>
> Consider:
> public class LongitudeLatitude
> {
>   protected double longitude;
>   protected double latitude;
> }
> public class LongitudeLatitudeCompositeUserType
>   implements CompositeUserType
> {
>   public String[] getPropertyNames()
>   {
>     return new String[] { "longitude", "latitude" };
>   }
>   public Type[] getPropertyTypes()
>   {
>     return new Type[] { Hibernate.DOUBLE, Hibernate.DOUBLE };
>   }
>   ...
> }
> @Entity
> public class Test
> {
>   @Basic(optional = false)
>   @Type(type = "foo.bar.LongitudeLatitudeCompositeUserType")
>   @Columns(columns = { @Column(name = "location_longitude"), @Column(name = "location_latitude") })
>   protected LongitudeLatitude location;
> }
> Why does the developer need to specify each column?
> I'd really rather let the CompositeUserType take care of that for me. Now, I have to tie the @Columns to the # of properties in my CompositeUserType AND the order in which they are defined? This seems to defeat the purpose of having a class (CompositeUserType) to tell Hibernate how to store it.
> Couldn't Hibernate prepend the property name 'location' and '_' to the front of each property name in the CompositeUserType?
> Perhaps (more than likely) I'm doing something wrong, but I get a failure if I do not specify the columns.
> Thanks,
> Michael

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list