Specifying the referencedColumnName in a @JoinColumn in backtics like `uid` fails

Description

Given a column with a defined name in backtics like so
@Id
@GeneratedValue
@Column(name = "`uid`")
private long userid;

A @JoinTable/@JoinColumn mapping fails if specifically referencing the backtic name, instead one must leave off the backtics so the discovery can happen based on the pk.

This fails:
@JoinTable(name = "SYS_GROUPS_USERS", joinColumns = @JoinColumn(name = "USERID", referencedColumnName = "`uid`"), inverseJoinColumns = @JoinColumn(name = "GROUPID", referencedColumnName = "GROUPID"))

While this works:
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "SYS_GROUPS_USERS", joinColumns = @JoinColumn(name = "USERID"), inverseJoinColumns = @JoinColumn(name = "GROUPID"))

The exception is
Caused by: org.hibernate.AnnotationException: Column name uid of org.domain.seam202.entity.SysUserOrm not found in JoinColumns.referencedColumnName
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:321)
at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1322)
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1161)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:600)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:323)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1225)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:159)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)

Environment

EAP 4.3 with Hibernate commons annotations 3.0.0.GA and Hibernate core 3.2.4.sp1.cp09

Activity

Show:
Anthony Patricio
April 12, 2010, 5:25 PM

parsing will fail with `
remove the ` and everything works fine.
Sounds located to referencedColumnName

Strong Liu
April 12, 2010, 5:40 PM

great, thanks for the test case, Anthony

https://jira.jboss.org/jira/browse/JBPAPP-4088

Strong Liu
April 13, 2010, 10:54 AM

fixed in trunk, will back port it to product branches soon

Steve Ebersole
March 21, 2011, 7:09 PM

Bulk closing stale resolved issues

Assignee

Strong Liu

Reporter

SamuelS

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure