[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5950) Make @UniqueConstraint inheritable

Manuel Bernhardt (JIRA) noreply at atlassian.com
Wed Feb 23 08:33:08 EST 2011


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

Manuel Bernhardt commented on HHH-5950:
---------------------------------------

We have a case where quite some (around 20) entities are assigned to a project. Additionally, those entities all have a natural identifier (so for each project, that identifier starts at 1). Hence (naturalId, project) should be unique. I preferred this approach (multi-column unique constraint) over using a real composite primary key because that seems to be complicating things quite a bit (and hey, the doc says that it should be used for legacy applications only :) )

So in the current situation I have to copy-paste the uniqueness constraint all over the place and I'm a bit worried that this may lead to issues on the long run (e.g. when forgetting the constraint for one entity, or when new members join the team...).

I agree that @UniqueConstraint is a physical concern. I'm wondering, is there a way to innovate on the UniqueConstraint so that could do more stuff than JPA? Because in that case, one way to address the abstract / concrete issue would be to add a propertyNames element to the annotation/mapping which then would apply to entity-level properties. And allowing to inherit an annotation of that kind would then perhaps make more sense. (of course, columnNames and propertyNames could not be used together).

> Make @UniqueConstraint inheritable
> ----------------------------------
>
>                 Key: HHH-5950
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5950
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: annotations
>    Affects Versions: 3.6.1
>            Reporter: Manuel Bernhardt
>
> It would be really nice to be able to define a @UniquenessConstraint in a @MappedSuperclass so that all subclasses carry this constraint. Right now, the following constraint is ignored:
> @MappedSuperclass
> @Table(uniqueConstraints = {@UniqueConstraint(name="inheritedConstraint", columnNames = {"matter", "value"})})
> public class Space { ... }

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