Details
-
Bug
-
Resolution: Done
-
Minor
-
4.3.0.GA_CP07, EAP 5.0.1.CR1, EAP 5.0.1.CR2, EAP 5.0.1
-
None
-
EAP 4.3 with Hibernate commons annotations 3.0.0.GA and Hibernate core 3.2.4.sp1.cp09
-
Release Notes
-
-
-
Documented as Resolved Issue
Description
[is related to http://opensource.atlassian.com/projects/hibernate/browse/HHH-5103]
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)