[hibernate-dev] Unidirectional @OneToMany @JoinColumn associations

Vlad Mihalcea mihalcea.vlad at gmail.com
Wed May 30 03:47:18 EDT 2018


Hi,

For the OneToMany with @JoinColumn, the user can workaround this limitation
by just using the @ManyToOne on the child side on any column they want
and turning the unidirectional association into a bidirectional one. I
remember I tested it and it worked just fine.

For the  OneToMany with @JoinTable, the only workaround would be if they
map the join table as an entity and use the @ManyToOne on the columns they
want
the association to be based on.

Since unidirectional associations don't perform that well, I'm not sure
whether it's worth adding support for these use cases.

Vlad

On Wed, May 30, 2018 at 9:32 AM, Gail Badner <gbadner at redhat.com> wrote:

> Unidirectional OneToMany associations using @JoinColumn that reference
> columns that are not PK columns is not currently supported.
>
> The JPA 2.1 documentation for @JoinTable says:
>
> "Support for referenced columns that are not primary key columns of the
> referenced table is optional. Applications that use such mappings will not
> be portable."
>
> I don't see anything in the user doc that explicitly states that Hibernate
> does not support this.
>
> Is this considered a bug?
>
> Also, what about a unidirectional OneToMany using a @JoinColumn that
> references some, but not all, of primary key columns? Hibernate does not
> support that either. Should Hibernate support it since they are primary key
> columns?
>
> Thanks,
> Gail
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list