-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping ManyToMany Unidirectional Relationship With Annot.
PostPosted: Tue Dec 20, 2005 6:37 pm 
Newbie

Joined: Tue Dec 28, 2004 7:41 pm
Posts: 7
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'


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.