Skip to content

Commit a917fc1

Browse files
info@kawoolutions.comSanne
authored andcommitted
HHH-14343 Test case for issue
1 parent 41f44ad commit a917fc1

File tree

7 files changed

+365
-0
lines changed

7 files changed

+365
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.mapping.hhh14343;
8+
9+
import org.hibernate.cfg.AvailableSettings;
10+
import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy;
11+
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
12+
import org.hibernate.test.mapping.hhh14343.entity.NestedPlayerStat;
13+
import org.hibernate.test.mapping.hhh14343.entity.NestedScore;
14+
import org.hibernate.test.mapping.hhh14343.entity.NestedStat;
15+
import org.hibernate.testing.TestForIssue;
16+
import org.junit.Before;
17+
import org.junit.Test;
18+
19+
import java.util.Map;
20+
21+
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
22+
23+
@TestForIssue(jiraKey = "HHH-14343")
24+
public class NestedIdClassTest extends BaseEntityManagerFunctionalTestCase {
25+
@Override
26+
protected Class<?>[] getAnnotatedClasses() {
27+
return new Class<?>[] {
28+
NestedStat.class,
29+
NestedPlayerStat.class,
30+
NestedScore.class
31+
};
32+
}
33+
34+
@Override
35+
protected void addConfigOptions(Map options) {
36+
options.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, Boolean.TRUE );
37+
options.put( AvailableSettings.HQL_BULK_ID_STRATEGY, InlineIdsOrClauseBulkIdStrategy.class.getName() );
38+
}
39+
40+
@Before
41+
public void setUp() {
42+
doInJPA( this::entityManagerFactory, em ->
43+
{
44+
// do nothing
45+
} );
46+
}
47+
48+
@Test
49+
public void testNestedIdClasses() {
50+
doInJPA( this::entityManagerFactory, em ->
51+
{
52+
// do nothing
53+
} );
54+
}
55+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.hibernate.test.mapping.hhh14343.entity;
2+
3+
import java.io.Serializable;
4+
5+
import javax.persistence.Basic;
6+
import javax.persistence.Column;
7+
import javax.persistence.Entity;
8+
import javax.persistence.FetchType;
9+
import javax.persistence.Id;
10+
import javax.persistence.IdClass;
11+
import javax.persistence.JoinColumn;
12+
import javax.persistence.ManyToOne;
13+
import javax.persistence.Table;
14+
15+
@Entity
16+
@Table(name = "\"PlayerStats\"")
17+
@IdClass(NestedPlayerStatId.class)
18+
public class NestedPlayerStat implements Serializable
19+
{
20+
private static final long serialVersionUID = 1L;
21+
22+
@Id
23+
@Column(name = "player_id")
24+
private Integer playerId;
25+
26+
@Basic(optional = false)
27+
@Column(name = "jersey_nbr")
28+
private Integer jerseyNbr;
29+
30+
@Id
31+
@ManyToOne(optional = false, fetch = FetchType.EAGER)
32+
@JoinColumn(name = "game_id", referencedColumnName = "game_id")
33+
@JoinColumn(name = "is_home", referencedColumnName = "is_home")
34+
private NestedScore score;
35+
36+
public NestedPlayerStat()
37+
{
38+
}
39+
40+
public Integer getPlayerId()
41+
{
42+
return playerId;
43+
}
44+
45+
public void setPlayerId(Integer playerId)
46+
{
47+
this.playerId = playerId;
48+
}
49+
50+
public Integer getJerseyNbr()
51+
{
52+
return jerseyNbr;
53+
}
54+
55+
public void setJerseyNbr(Integer jerseyNbr)
56+
{
57+
this.jerseyNbr = jerseyNbr;
58+
}
59+
60+
public NestedScore getScore()
61+
{
62+
return score;
63+
}
64+
65+
public void setScore(NestedScore score)
66+
{
67+
this.score = score;
68+
}
69+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.hibernate.test.mapping.hhh14343.entity;
2+
3+
import java.io.Serializable;
4+
5+
public class NestedPlayerStatId implements Serializable
6+
{
7+
private static final long serialVersionUID = 1L;
8+
9+
private Integer playerId;
10+
11+
private NestedScoreId score;
12+
13+
public NestedPlayerStatId()
14+
{
15+
}
16+
17+
public Integer getPlayerId()
18+
{
19+
return playerId;
20+
}
21+
22+
public void setPlayerId(Integer playerId)
23+
{
24+
this.playerId = playerId;
25+
}
26+
27+
public NestedScoreId getScore()
28+
{
29+
return score;
30+
}
31+
32+
public void setScore(NestedScoreId score)
33+
{
34+
this.score = score;
35+
}
36+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package org.hibernate.test.mapping.hhh14343.entity;
2+
3+
import java.io.Serializable;
4+
5+
import javax.persistence.Basic;
6+
import javax.persistence.Column;
7+
import javax.persistence.Entity;
8+
import javax.persistence.Id;
9+
import javax.persistence.IdClass;
10+
import javax.persistence.Table;
11+
12+
@Entity
13+
@Table(name = "\"Scores\"")
14+
@IdClass(NestedScoreId.class)
15+
public class NestedScore implements Serializable
16+
{
17+
private static final long serialVersionUID = 1L;
18+
19+
@Id
20+
@Column(name = "game_id")
21+
private Integer gameId;
22+
23+
@Id
24+
@Column(name = "is_home")
25+
private Boolean home;
26+
27+
@Basic(optional = false)
28+
@Column(name = "roster_id")
29+
private Integer rosterId;
30+
31+
@Basic
32+
@Column(name = "final_score")
33+
private Integer finalScore;
34+
35+
public NestedScore()
36+
{
37+
}
38+
39+
public Integer getGameId()
40+
{
41+
return gameId;
42+
}
43+
44+
public void setGameId(Integer gameId)
45+
{
46+
this.gameId = gameId;
47+
}
48+
49+
public Boolean getHome()
50+
{
51+
return home;
52+
}
53+
54+
public void setHome(Boolean home)
55+
{
56+
this.home = home;
57+
}
58+
59+
public Integer getRosterId()
60+
{
61+
return rosterId;
62+
}
63+
64+
public void setRosterId(Integer rosterId)
65+
{
66+
this.rosterId = rosterId;
67+
}
68+
69+
public Integer getFinalScore()
70+
{
71+
return finalScore;
72+
}
73+
74+
public void setFinalScore(Integer finalScore)
75+
{
76+
this.finalScore = finalScore;
77+
}
78+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.hibernate.test.mapping.hhh14343.entity;
2+
3+
import java.io.Serializable;
4+
5+
public class NestedScoreId implements Serializable
6+
{
7+
private static final long serialVersionUID = 1L;
8+
9+
private Integer gameId;
10+
11+
private Boolean home;
12+
13+
public NestedScoreId()
14+
{
15+
}
16+
17+
public Integer getGameId()
18+
{
19+
return gameId;
20+
}
21+
22+
public void setGameId(Integer gameId)
23+
{
24+
this.gameId = gameId;
25+
}
26+
27+
public Boolean getHome()
28+
{
29+
return home;
30+
}
31+
32+
public void setHome(Boolean home)
33+
{
34+
this.home = home;
35+
}
36+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.hibernate.test.mapping.hhh14343.entity;
2+
3+
import java.io.Serializable;
4+
5+
import javax.persistence.Column;
6+
import javax.persistence.Entity;
7+
import javax.persistence.FetchType;
8+
import javax.persistence.Id;
9+
import javax.persistence.IdClass;
10+
import javax.persistence.JoinColumn;
11+
import javax.persistence.ManyToOne;
12+
import javax.persistence.Table;
13+
14+
@Entity
15+
@Table(name = "\"Stats\"")
16+
@IdClass(NestedStatId.class)
17+
public class NestedStat implements Serializable
18+
{
19+
private static final long serialVersionUID = 1L;
20+
21+
@Id
22+
@Column
23+
private Integer period;
24+
25+
@Id
26+
@ManyToOne(optional = false, fetch = FetchType.EAGER)
27+
@JoinColumn(name = "game_id", referencedColumnName = "game_id")
28+
@JoinColumn(name = "is_home", referencedColumnName = "is_home")
29+
@JoinColumn(name = "player_id", referencedColumnName = "player_id")
30+
private NestedPlayerStat playerStat;
31+
32+
public NestedStat()
33+
{
34+
}
35+
36+
public Integer getPeriod()
37+
{
38+
return period;
39+
}
40+
41+
public void setPeriod(Integer period)
42+
{
43+
this.period = period;
44+
}
45+
46+
public NestedPlayerStat getPlayerStat()
47+
{
48+
return playerStat;
49+
}
50+
51+
public void setPlayerStat(NestedPlayerStat playerStat)
52+
{
53+
this.playerStat = playerStat;
54+
}
55+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.hibernate.test.mapping.hhh14343.entity;
2+
3+
import java.io.Serializable;
4+
5+
public class NestedStatId implements Serializable
6+
{
7+
private static final long serialVersionUID = 1L;
8+
9+
private Integer period;
10+
11+
private NestedPlayerStatId playerStat;
12+
13+
public NestedStatId()
14+
{
15+
}
16+
17+
public Integer getPeriod()
18+
{
19+
return period;
20+
}
21+
22+
public void setPeriod(Integer period)
23+
{
24+
this.period = period;
25+
}
26+
27+
public NestedPlayerStatId getPlayerStat()
28+
{
29+
return playerStat;
30+
}
31+
32+
public void setPlayerStat(NestedPlayerStatId playerStat)
33+
{
34+
this.playerStat = playerStat;
35+
}
36+
}

0 commit comments

Comments
 (0)