@Embeddable ignores "length" attribute for @Column

Description

I've before created a question on StackOverflow (with code examples): http://stackoverflow.com/questions/18937049/embeddable-wont-set-length-of-columns

The problem is simply, when using "@Column(name="MyColumn", length=16)" inside an "@Embeddable" class. Then the column name gets set correctly, but the length gets ignored (set to 255). In addition hibernate tells MySQL to set some default value for the column (in my case: "\0\0\0\0...\0\0\0\0").

It doesn't matter if I use (as in the StackOverflow code) an @Embeddable inside a @MappedSuperclass. Or if I create a completely separate class for the @Embeddable.

Attachments

1
  • 14 Sep 2014, 11:37 AM

Activity

Show:

Christian Beikov January 21, 2025 at 11:18 AM

Chris Cranford May 27, 2016 at 6:46 PM
Edited

This issue seems to be related to the inclusion of @MapsId in conjunction with a @JoinColumn. If the mapping is changed to either of the following, the right column length is derived.

JoinColumn w/no MapsId

@ManyToOne @JoinColumn(name = "FK_A", nullable = false, insertable = false, updatable = false) private EntityA a;

MapsId w/no JoinColumn

@MapsId @ManyToOne private EntityA a;

Hack Kampbjørn May 19, 2016 at 9:20 AM

This affects 5.0.9, when using a @JoinColumn(name="some name") then length attribute from @Embeddable is lost. The workaround is to explicitly set columnDefinition in the @JoinColumn again

Steve Ebersole October 28, 2015 at 3:24 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Steve Ebersole October 27, 2015 at 7:15 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Duplicate

Details

Assignee

Reporter

Labels

Affects versions

Priority

Created September 21, 2013 at 8:45 PM
Updated January 21, 2025 at 11:18 AM
Resolved January 21, 2025 at 11:18 AM