New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection/Map join table column default names can be incorrect for JPA #175

Closed
andyjefferson opened this Issue Mar 14, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@andyjefferson
Member

andyjefferson commented Mar 14, 2017

The code will currently use specified column names for join table column naming correctly, however if the user has not provided any column names, then will default to (seemingly) incorrect values based on the PK column name(s) of the element/key/value.

For JDO there is no defined schema default namings, so it is not strictly speaking a bug in that case.
For JPA, the spec says "The MapKey(Join)Column annotation is used to specify the mapping for the key column of a map whose map key is a basic type. If the name element is not specified, it defaults to the concatenation of the following: the name of the referencing relationship field or property and _KEY"

Note this only applies to the case of persistable element/key/value.

An example

public class Holder
{
    @OneToMany
    @JoinTable
    Map<Key, Value> myMap;
}

public class Key
{
    @Id
    long id;
}
public class Value
{
    @Id
    long id;
}

will result in an attempt to create a join table with column "MYMAP_ID" for the key FK and "MYMAP_ID" for the value FK.

Workaround : Specify @MapKeyColumn. Arguably this should be @mapkeyJoinColumn.

@andyjefferson andyjefferson added the bug label Mar 14, 2017

@andyjefferson andyjefferson added this to the 5.1.0.m1 milestone Mar 14, 2017

@andyjefferson andyjefferson changed the title from Collection/Map join table column default names can be incorrect to Collection/Map join table column default names can be incorrect for JPA Mar 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment