File tree Expand file tree Collapse file tree 3 files changed +21
-15
lines changed
main/java/org/hibernate/boot/model/naming
test/java/org/hibernate/id/idclass Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import org .hibernate .boot .model .source .spi .AttributePath ;
10
10
import org .hibernate .internal .util .StringHelper ;
11
+ import org .hibernate .loader .PropertyPath ;
11
12
12
13
/**
13
14
* An ImplicitNamingStrategy implementation which uses full composite paths
@@ -30,14 +31,17 @@ protected String transformAttributePath(AttributePath attributePath) {
30
31
}
31
32
32
33
public static void process (AttributePath attributePath , StringBuilder sb ) {
33
- if ( attributePath .getParent () != null ) {
34
- process ( attributePath .getParent (), sb );
35
- if ( StringHelper .isNotEmpty ( attributePath .getParent ().getProperty () ) ) {
36
- sb .append ( '_' );
37
- }
38
- }
39
-
40
34
String property = attributePath .getProperty ();
35
+ final AttributePath parent = attributePath .getParent ();
36
+ if ( parent != null && StringHelper .isNotEmpty ( parent .getProperty () ) ) {
37
+ process ( parent , sb );
38
+ sb .append ( '_' );
39
+ }
40
+ else if ( PropertyPath .IDENTIFIER_MAPPER_PROPERTY .equals ( property ) ) {
41
+ // skip it, do not pass go
42
+ sb .append ( "id" );
43
+ return ;
44
+ }
41
45
property = property .replace ( "<" , "" );
42
46
property = property .replace ( ">" , "" );
43
47
Original file line number Diff line number Diff line change 9
9
import org .hibernate .boot .model .naming .ImplicitNamingStrategyComponentPathImpl ;
10
10
import org .hibernate .cfg .Configuration ;
11
11
12
+ import org .hibernate .testing .TestForIssue ;
12
13
import org .hibernate .testing .junit4 .BaseCoreFunctionalTestCase ;
13
14
import org .junit .Test ;
14
15
@@ -21,22 +22,23 @@ protected Class<?>[] getAnnotatedClasses() {
21
22
22
23
@ Override
23
24
protected void configure (Configuration configuration ) {
24
- /*
25
- * With this implicit naming strategy, we got the following mapping:
26
- *
27
- * create table MyEntity (
25
+ /*
26
+ * With this implicit naming strategy, we got the following mapping:
27
+ *
28
+ * create table MyEntity (
28
29
* id_idA bigint not null,
29
30
* id_idB bigint not null,
30
31
* _identifierMapper_idA bigint not null, <-- ??
31
32
* _identifierMapper_idB bigint not null, <-- ??
32
33
* notes varchar(255),
33
34
* primary key (id_idA, id_idB)
34
35
* )
35
- */
36
+ */
36
37
configuration .setImplicitNamingStrategy ( new ImplicitNamingStrategyComponentPathImpl () );
37
38
}
38
39
39
40
@ Test
41
+ @ TestForIssue (jiraKey = "HHH-14241" )
40
42
public void test () {
41
43
inTransaction ( ( session ) -> {
42
44
MyEntity entity = new MyEntity ();
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ public class MyEntity {
23
23
private String notes ;
24
24
25
25
public MyEntityId getId () {
26
- return new MyEntityId ( idB , idA );
26
+ return new MyEntityId ( idA , idB );
27
27
}
28
28
29
29
public void setId (MyEntityId id ) {
30
- this .idB = id .getIdA ();
31
- this .idA = id .getIdB ();
30
+ this .idA = id .getIdA ();
31
+ this .idB = id .getIdB ();
32
32
}
33
33
34
34
public String getNotes () {
You can’t perform that action at this time.
0 commit comments