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" />
  	</bag>

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

Sreekumar Kj
Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics. He now runs a conversational AI company - DheeYantra - focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.