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

Xavier Dury (JIRA) noreply at atlassian.com
Fri Nov 20 09:14:08 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34697#action_34697 ] 

Xavier Dury commented on HHH-4347:
----------------------------------

please, some smart defaults would be very nice to have =) I think many people are using hibernate as their main jpa implementation because of all the useful things not covered by the specification... and user types are one of them. For my part, I have a composite user type for joda-time intervals and it would be nice if I wasn't forced to put @Columns everywhere.

> use property names defined in CompositeUserType as default column names
> -----------------------------------------------------------------------
>
>                 Key: HHH-4347
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4347
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: annotations
>            Reporter: Michael Newcomb
>            Priority: Minor
>
> 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.
-
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