HHH-5103 Specifying the referencedColumnName in a @JoinColumn in backtics like fails
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19218 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
780666b65a
commit
d4de388e61
|
@ -446,7 +446,7 @@ public class TableBinder {
|
|||
String referencedColumn = joinCol.getReferencedColumn();
|
||||
referencedColumn = mappings.getPhysicalColumnName( referencedColumn, table );
|
||||
//In JPA 2 referencedColumnName is case insensitive
|
||||
if ( referencedColumn.equalsIgnoreCase( col.getName() ) ) {
|
||||
if ( referencedColumn.equalsIgnoreCase( col.getQuotedName() ) ) {
|
||||
//proper join column
|
||||
if ( joinCol.isNameDeferred() ) {
|
||||
joinCol.linkValueUsingDefaultColumnNaming(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.join;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
|
@ -114,7 +115,20 @@ public class JoinTest extends TestCase {
|
|||
tx.commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
|
||||
public void testReferenceColumnWithBacktics() throws Exception {
|
||||
Session s=openSession();
|
||||
s.beginTransaction();
|
||||
SysGroupsOrm g=new SysGroupsOrm();
|
||||
SysUserOrm u=new SysUserOrm();
|
||||
u.setGroups( new ArrayList<SysGroupsOrm>() );
|
||||
u.getGroups().add( g );
|
||||
s.save( g );
|
||||
s.save( u );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public void testUniqueConstaintOnSecondaryTable() throws Exception {
|
||||
Cat cat = new Cat();
|
||||
cat.setStoryPart2( "My long story" );
|
||||
|
@ -200,7 +214,9 @@ public class JoinTest extends TestCase {
|
|||
Dog.class,
|
||||
A.class,
|
||||
B.class,
|
||||
C.class
|
||||
C.class,
|
||||
SysGroupsOrm.class,
|
||||
SysUserOrm.class
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.hibernate.test.annotations.join;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table( name = "SYS_GROUPS" )
|
||||
public class SysGroupsOrm {
|
||||
|
||||
private long groupId;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column( name = "GROUPID" )
|
||||
public long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId( long groupId ) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.hibernate.test.annotations.join;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity( name = "sys_user" )
|
||||
@Table( name = "SYS_USER" )
|
||||
public class SysUserOrm {
|
||||
|
||||
private long userid;
|
||||
|
||||
private Collection<SysGroupsOrm> groups;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column( name = "`auid`" )
|
||||
public long getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid( long userid ) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
@ManyToMany( fetch = FetchType.LAZY )
|
||||
@JoinTable( name = "SYS_GROUPS_USERS",
|
||||
joinColumns = @JoinColumn( name = "USERID", referencedColumnName = "`auid`" ),
|
||||
inverseJoinColumns = @JoinColumn( name = "GROUPID", referencedColumnName = "GROUPID" ) )
|
||||
public Collection<SysGroupsOrm> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups( Collection<SysGroupsOrm> groups ) {
|
||||
this.groups = groups;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue