[hibernate-issues] [Hibernate-JIRA] Created: (HHH-7271) Foreign key properties need to allow mixing nullable and non-nullable keys

Joachim Durchholz (JIRA) noreply at atlassian.com
Tue Apr 24 09:41:50 EDT 2012


Foreign key properties need to allow mixing nullable and non-nullable keys
--------------------------------------------------------------------------

                 Key: HHH-7271
                 URL: https://hibernate.onjira.com/browse/HHH-7271
             Project: Hibernate ORM
          Issue Type: Improvement
          Components: annotations
    Affects Versions: 3.6.10
         Environment: 3.6.10, Oracle 10g (probably irrelevant)
            Reporter: Joachim Durchholz


Tables L and R are in an optional relationship.
L's foreign key into R is composite and consists of two fields: K1 and K2. (This also means that R's primary key consists of two fields, which happen to also be named K1 and K2.)
L1 is part of L's primary key, so it can't be nullable.
L2 is nullable. It must be because otherwise the relationship would not be optional.

This works in standard hibernate, but Hibernate Annotations gives me this error:
"Mixing nullable and non nullable columns in a property is not allowed"

I could switch to using a synthetic PK on R. However, that would introduce an unwanted redundancy: L would not be allowed to link to a row in R that has diverging K1 and K2 fields.
The fields need to be present both in L and R, because the relationship is optional in both directions.

I do not understand why there is such a restriction in Annotations in the first place.
Even the other use of multi-column properties that I'm aware of, user types, seems to lose rather than win from it.

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