Test case for HHH-14343
This commit is contained in:
parent
e2dbf52abe
commit
3434293a7e
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.mapping.hhh14343;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.test.mapping.hhh14343.entity.NestedPlayerStat;
|
||||
import org.hibernate.test.mapping.hhh14343.entity.NestedScore;
|
||||
import org.hibernate.test.mapping.hhh14343.entity.NestedStat;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-14343")
|
||||
public class NestedIdClassTest extends BaseEntityManagerFunctionalTestCase {
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
NestedStat.class,
|
||||
NestedPlayerStat.class,
|
||||
NestedScore.class
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, Boolean.TRUE );
|
||||
options.put( AvailableSettings.HQL_BULK_ID_STRATEGY, InlineIdsOrClauseBulkIdStrategy.class.getName() );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
doInJPA( this::entityManagerFactory, em ->
|
||||
{
|
||||
// do nothing
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedIdClasses() {
|
||||
doInJPA( this::entityManagerFactory, em ->
|
||||
{
|
||||
// do nothing
|
||||
} );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package org.hibernate.test.mapping.hhh14343.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"PlayerStats\"")
|
||||
@IdClass(NestedPlayerStatId.class)
|
||||
public class NestedPlayerStat implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column(name = "player_id")
|
||||
private Integer playerId;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "jersey_nbr")
|
||||
private Integer jerseyNbr;
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "game_id", referencedColumnName = "game_id")
|
||||
@JoinColumn(name = "is_home", referencedColumnName = "is_home")
|
||||
private NestedScore score;
|
||||
|
||||
public NestedPlayerStat()
|
||||
{
|
||||
}
|
||||
|
||||
public Integer getPlayerId()
|
||||
{
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public void setPlayerId(Integer playerId)
|
||||
{
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public Integer getJerseyNbr()
|
||||
{
|
||||
return jerseyNbr;
|
||||
}
|
||||
|
||||
public void setJerseyNbr(Integer jerseyNbr)
|
||||
{
|
||||
this.jerseyNbr = jerseyNbr;
|
||||
}
|
||||
|
||||
public NestedScore getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(NestedScore score)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.hibernate.test.mapping.hhh14343.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NestedPlayerStatId implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer playerId;
|
||||
|
||||
private NestedScoreId score;
|
||||
|
||||
public NestedPlayerStatId()
|
||||
{
|
||||
}
|
||||
|
||||
public Integer getPlayerId()
|
||||
{
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public void setPlayerId(Integer playerId)
|
||||
{
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public NestedScoreId getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(NestedScoreId score)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.hibernate.test.mapping.hhh14343.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"Scores\"")
|
||||
@IdClass(NestedScoreId.class)
|
||||
public class NestedScore implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column(name = "game_id")
|
||||
private Integer gameId;
|
||||
|
||||
@Id
|
||||
@Column(name = "is_home")
|
||||
private Boolean home;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "roster_id")
|
||||
private Integer rosterId;
|
||||
|
||||
@Basic
|
||||
@Column(name = "final_score")
|
||||
private Integer finalScore;
|
||||
|
||||
public NestedScore()
|
||||
{
|
||||
}
|
||||
|
||||
public Integer getGameId()
|
||||
{
|
||||
return gameId;
|
||||
}
|
||||
|
||||
public void setGameId(Integer gameId)
|
||||
{
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
public Boolean getHome()
|
||||
{
|
||||
return home;
|
||||
}
|
||||
|
||||
public void setHome(Boolean home)
|
||||
{
|
||||
this.home = home;
|
||||
}
|
||||
|
||||
public Integer getRosterId()
|
||||
{
|
||||
return rosterId;
|
||||
}
|
||||
|
||||
public void setRosterId(Integer rosterId)
|
||||
{
|
||||
this.rosterId = rosterId;
|
||||
}
|
||||
|
||||
public Integer getFinalScore()
|
||||
{
|
||||
return finalScore;
|
||||
}
|
||||
|
||||
public void setFinalScore(Integer finalScore)
|
||||
{
|
||||
this.finalScore = finalScore;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.hibernate.test.mapping.hhh14343.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NestedScoreId implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer gameId;
|
||||
|
||||
private Boolean home;
|
||||
|
||||
public NestedScoreId()
|
||||
{
|
||||
}
|
||||
|
||||
public Integer getGameId()
|
||||
{
|
||||
return gameId;
|
||||
}
|
||||
|
||||
public void setGameId(Integer gameId)
|
||||
{
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
public Boolean getHome()
|
||||
{
|
||||
return home;
|
||||
}
|
||||
|
||||
public void setHome(Boolean home)
|
||||
{
|
||||
this.home = home;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.hibernate.test.mapping.hhh14343.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"Stats\"")
|
||||
@IdClass(NestedStatId.class)
|
||||
public class NestedStat implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column
|
||||
private Integer period;
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "game_id", referencedColumnName = "game_id")
|
||||
@JoinColumn(name = "is_home", referencedColumnName = "is_home")
|
||||
@JoinColumn(name = "player_id", referencedColumnName = "player_id")
|
||||
private NestedPlayerStat playerStat;
|
||||
|
||||
public NestedStat()
|
||||
{
|
||||
}
|
||||
|
||||
public Integer getPeriod()
|
||||
{
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(Integer period)
|
||||
{
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public NestedPlayerStat getPlayerStat()
|
||||
{
|
||||
return playerStat;
|
||||
}
|
||||
|
||||
public void setPlayerStat(NestedPlayerStat playerStat)
|
||||
{
|
||||
this.playerStat = playerStat;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.hibernate.test.mapping.hhh14343.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NestedStatId implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer period;
|
||||
|
||||
private NestedPlayerStatId playerStat;
|
||||
|
||||
public NestedStatId()
|
||||
{
|
||||
}
|
||||
|
||||
public Integer getPeriod()
|
||||
{
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(Integer period)
|
||||
{
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public NestedPlayerStatId getPlayerStat()
|
||||
{
|
||||
return playerStat;
|
||||
}
|
||||
|
||||
public void setPlayerStat(NestedPlayerStatId playerStat)
|
||||
{
|
||||
this.playerStat = playerStat;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue