HHH-14241 Support ImplicitNamingStrategyComponentPathImpl with IdClass
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
03416a8cdd
commit
8d4de09255
|
@ -8,6 +8,7 @@ package org.hibernate.boot.model.naming;
|
||||||
|
|
||||||
import org.hibernate.boot.model.source.spi.AttributePath;
|
import org.hibernate.boot.model.source.spi.AttributePath;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
import org.hibernate.loader.PropertyPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ImplicitNamingStrategy implementation which uses full composite paths
|
* An ImplicitNamingStrategy implementation which uses full composite paths
|
||||||
|
@ -30,14 +31,17 @@ public class ImplicitNamingStrategyComponentPathImpl extends ImplicitNamingStrat
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void process(AttributePath attributePath, StringBuilder sb) {
|
public static void process(AttributePath attributePath, StringBuilder sb) {
|
||||||
if ( attributePath.getParent() != null ) {
|
String property = attributePath.getProperty();
|
||||||
process( attributePath.getParent(), sb );
|
final AttributePath parent = attributePath.getParent();
|
||||||
if ( StringHelper.isNotEmpty( attributePath.getParent().getProperty() ) ) {
|
if ( parent != null && StringHelper.isNotEmpty( parent.getProperty() ) ) {
|
||||||
|
process( parent, sb );
|
||||||
sb.append( '_' );
|
sb.append( '_' );
|
||||||
}
|
}
|
||||||
|
else if ( PropertyPath.IDENTIFIER_MAPPER_PROPERTY.equals( property ) ) {
|
||||||
|
// skip it, do not pass go
|
||||||
|
sb.append( "id" );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String property = attributePath.getProperty();
|
|
||||||
property = property.replace( "<", "" );
|
property = property.replace( "<", "" );
|
||||||
property = property.replace( ">", "" );
|
property = property.replace( ">", "" );
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.id.idclass;
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ public class IdClassNamingStrategyTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-14241")
|
||||||
public void test() {
|
public void test() {
|
||||||
inTransaction( ( session ) -> {
|
inTransaction( ( session ) -> {
|
||||||
MyEntity entity = new MyEntity();
|
MyEntity entity = new MyEntity();
|
||||||
|
|
|
@ -23,12 +23,12 @@ public class MyEntity {
|
||||||
private String notes;
|
private String notes;
|
||||||
|
|
||||||
public MyEntityId getId() {
|
public MyEntityId getId() {
|
||||||
return new MyEntityId( idB, idA );
|
return new MyEntityId( idA, idB );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(MyEntityId id) {
|
public void setId(MyEntityId id) {
|
||||||
this.idB = id.getIdA();
|
this.idA = id.getIdA();
|
||||||
this.idA = id.getIdB();
|
this.idB = id.getIdB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNotes() {
|
public String getNotes() {
|
||||||
|
|
Loading…
Reference in New Issue