Solution to MySQLSyntaxErrorException: Unknown column ‘xxxxx_.elt’ in ‘field list’

Bug: The above exception thrown when using hibernate.

Reason: This usually occurs when column name is not mentioned in many-to-many node.
The correct mapping for a many to many relation is –

  	<bag name="projects".... table="users_projects" >
  		<key column="userId"/>
  		<many-to-many column="projectId" class="Project" />

Solution: The mapped columns should be provided in the key and many-to-many nodes as above.

Leave a Reply

Your email address will not be published. Required fields are marked *


* Copy This Password *

* Type Or Paste Password Here *

68,488 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>