I'm trying to do a simple unidirectional many-to-many mapping with annotations. For some reason the inverseJoinColumn appears to be ignored and 'elt' is used in it's place. The join table has two columns profile_id and role_code that map to the primary keys in their associated parent tables. The only thing worth noting is that the primary key in Role is defined as
@Id
@Column(name = "role_code")
public String getCode()
Hibernate version:
3.1beta6
Mapping documents:
@ManyToMany(targetEntity = Role.class,
cascade = {CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
@JoinTable(table = @Table(name = "profile.role_profile_assoc"),
joinColumns = {@JoinColumn(name = "profile_id", nullable = false) },
inverseJoinColumns = {@JoinColumn(name = "role_code", nullable = false) })
public Set<Role> getRoles()
Name and version of the database you are using:
MySQL 4.1.14-standard
The generated SQL (show_sql=true):
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not load an entity: [foo.ColonyProfile#1]; bad SQL grammar [select colonyprof0_.profile_id as profile1_6_0_, colonyprof0_.login as login6_0_, colonyprof0_.first_name as first3_6_0_, colonyprof0_.last_name as last4_6_0_, colonyprof0_.birth_year as birth5_6_0_, colonyprof0_.email_address as email6_6_0_, colonyprof0_.postalCode as postalCode6_0_, colonyprof0_.last_login as last8_6_0_, colonyprof0_.email_verified as email9_6_0_, colonyprof0_.created as created6_0_, colonyprof0_.gender as gender6_0_, colonyprof0_.newsletter as newsletter6_0_, colonyprof0_.blog_name as blog13_6_0_, colonyprof0_.blog_url as blog14_6_0_, colonyprof0_.image_url as image15_6_0_, colonyprof0_.phone as phone6_0_, colonyprof0_.last_modified as last17_6_0_, colonyprof0_.language_code as language18_6_0_, colonyprof0_.country_code as country19_6_0_, colonyprof0_.active as active6_0_, colonyprof0_.password as password6_0_, roles1_.profile_id as profile1_2_, roles1_.elt as elt2_ from profile.profile colonyprof0_ left outer join profile.role_profile_assoc roles1_ on colonyprof0_.profile_id=roles1_.profile_id where colonyprof0_.profile_id=?]; nested exception is java.sql.SQLException: Unknown column 'roles1_.elt' in 'field list'
|