HHH-14276 Amend style and formatting

This commit is contained in:
Sanne Grinovero 2020-11-16 12:07:42 +00:00
parent d1ee641e54
commit f9cce5a767
5 changed files with 296 additions and 313 deletions

View File

@ -1,53 +1,54 @@
package org.hibernate.test.mapping.hhh14276; /*
* Hibernate, Relational Persistence for Idiomatic Java
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
import java.util.Map; * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
import org.hibernate.cfg.AvailableSettings; package org.hibernate.test.mapping.hhh14276;
import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import org.hibernate.test.mapping.hhh14276.entity.PlayerStat;
import org.hibernate.test.mapping.hhh14276.entity.Score; import java.util.Map;
import org.hibernate.testing.TestForIssue;
import org.junit.Before; import org.hibernate.cfg.AvailableSettings;
import org.junit.Test; import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
/**
* This template demonstrates how to develop a test case for Hibernate ORM, using the Java Persistence API. import org.hibernate.test.mapping.hhh14276.entity.PlayerStat;
*/ import org.hibernate.test.mapping.hhh14276.entity.Score;
@TestForIssue( jiraKey = "HHH-14276" ) import org.hibernate.testing.TestForIssue;
public class NestedIdClassDerivedIdentifiersTest extends BaseEntityManagerFunctionalTestCase import org.junit.Before;
{ import org.junit.Test;
@Override
protected Class<?>[] getAnnotatedClasses() @TestForIssue(jiraKey = "HHH-14276")
{ public class NestedIdClassDerivedIdentifiersTest extends BaseEntityManagerFunctionalTestCase {
return new Class<?>[] { PlayerStat.class, @Override
Score.class }; protected Class<?>[] getAnnotatedClasses() {
} return new Class<?>[] {
PlayerStat.class,
@Override Score.class
protected void addConfigOptions( Map options ) };
{ }
options.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, Boolean.TRUE );
options.put( AvailableSettings.HQL_BULK_ID_STRATEGY, InlineIdsOrClauseBulkIdStrategy.class.getName() ); @Override
} protected void addConfigOptions(Map options) {
options.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, Boolean.TRUE );
@Before options.put( AvailableSettings.HQL_BULK_ID_STRATEGY, InlineIdsOrClauseBulkIdStrategy.class.getName() );
public void setUp() }
{
doInJPA( this::entityManagerFactory, em -> @Before
{ public void setUp() {
// do nothing doInJPA( this::entityManagerFactory, em ->
} ); {
} // do nothing
} );
@Test }
public void testNestedIdClassDerivedIdentifiers() throws Exception
{ @Test
doInJPA( this::entityManagerFactory, em -> public void testNestedIdClassDerivedIdentifiers() {
{ doInJPA( this::entityManagerFactory, em ->
// do nothing {
}); // do nothing
} } );
} }
}

View File

@ -1,89 +1,82 @@
package org.hibernate.test.mapping.hhh14276.entity; /*
* Hibernate, Relational Persistence for Idiomatic Java
import java.io.Serializable; *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
import javax.persistence.Basic; * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
import javax.persistence.Column; */
import javax.persistence.Entity; package org.hibernate.test.mapping.hhh14276.entity;
import javax.persistence.FetchType;
import javax.persistence.Id; import java.io.Serializable;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn; import javax.persistence.Basic;
import javax.persistence.ManyToOne; import javax.persistence.Column;
import javax.persistence.Table; import javax.persistence.Entity;
import javax.persistence.FetchType;
@Entity import javax.persistence.Id;
@Table(name = "\"PlayerStats\"") import javax.persistence.IdClass;
@IdClass(PlayerStatId.class) import javax.persistence.JoinColumn;
public class PlayerStat implements Serializable import javax.persistence.ManyToOne;
{ import javax.persistence.Table;
private static final long serialVersionUID = 1L;
@Entity
@Id @Table(name = "\"PlayerStats\"")
@Column(name = "player_id") @IdClass(PlayerStatId.class)
private Integer playerId; public class PlayerStat implements Serializable {
@Basic(optional = false) @Id
@Column(name = "jersey_nbr") @Column(name = "player_id")
private Integer jerseyNbr; private Integer playerId;
@Id @Basic(optional = false)
@ManyToOne(optional = false, fetch = FetchType.EAGER) @Column(name = "jersey_nbr")
@JoinColumn(name = "game_id", referencedColumnName = "game_id") private Integer jerseyNbr;
@JoinColumn(name = "is_home", referencedColumnName = "is_home")
private Score score; @Id
@ManyToOne(optional = false, fetch = FetchType.EAGER)
public PlayerStat() @JoinColumn(name = "game_id", referencedColumnName = "game_id")
{ @JoinColumn(name = "is_home", referencedColumnName = "is_home")
} private Score score;
public Integer getGameId() public PlayerStat() {
{ }
return score.getGameId();
} public Integer getGameId() {
return score.getGameId();
public void setGameId(Integer gameId) }
{
score.setGameId(gameId); public void setGameId(Integer gameId) {
} score.setGameId( gameId );
}
public Boolean getHome()
{ public Boolean getHome() {
return score.getHome(); return score.getHome();
} }
public void setHome(Boolean home) public void setHome(Boolean home) {
{ score.setHome( home );
score.setHome(home); }
}
public Integer getPlayerId() {
public Integer getPlayerId() return playerId;
{ }
return playerId;
} public void setPlayerId(Integer playerId) {
this.playerId = playerId;
public void setPlayerId(Integer playerId) }
{
this.playerId = playerId; public Integer getJerseyNbr() {
} return jerseyNbr;
}
public Integer getJerseyNbr()
{ public void setJerseyNbr(Integer jerseyNbr) {
return jerseyNbr; this.jerseyNbr = jerseyNbr;
} }
public void setJerseyNbr(Integer jerseyNbr) public Score getScore() {
{ return score;
this.jerseyNbr = jerseyNbr; }
}
public void setScore(Score score) {
public Score getScore() this.score = score;
{ }
return score; }
}
public void setScore(Score score)
{
this.score = score;
}
}

View File

@ -1,57 +1,52 @@
package org.hibernate.test.mapping.hhh14276.entity; /*
* Hibernate, Relational Persistence for Idiomatic Java
import java.io.Serializable; *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
public class PlayerStatId implements Serializable * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
{ */
private static final long serialVersionUID = 1L; package org.hibernate.test.mapping.hhh14276.entity;
private Integer playerId; import java.io.Serializable;
// nested composite PK @IdClass: named like relationship in entity class public class PlayerStatId implements Serializable {
private ScoreId score;
private Integer playerId;
public PlayerStatId()
{ // nested composite PK @IdClass: named like relationship in entity class
} private ScoreId score;
public Integer getGameId() public PlayerStatId() {
{ }
return score.getGameId();
} public Integer getGameId() {
return score.getGameId();
public void setGameId(Integer gameId) }
{
score.setGameId(gameId); public void setGameId(Integer gameId) {
} score.setGameId( gameId );
}
public Boolean getHome()
{ public Boolean getHome() {
return score.getHome(); return score.getHome();
} }
public void setHome(Boolean home) public void setHome(Boolean home) {
{ score.setHome( home );
score.setHome(home); }
}
public Integer getPlayerId() {
public Integer getPlayerId() return playerId;
{ }
return playerId;
} public void setPlayerId(Integer playerId) {
this.playerId = playerId;
public void setPlayerId(Integer playerId) }
{
this.playerId = playerId; public ScoreId getScoreId() {
} return score;
}
public ScoreId getScoreId()
{ public void setScoreId(ScoreId scoreId) {
return score; this.score = scoreId;
} }
}
public void setScoreId(ScoreId scoreId)
{
this.score = scoreId;
}
}

View File

@ -1,78 +1,73 @@
package org.hibernate.test.mapping.hhh14276.entity; /*
* Hibernate, Relational Persistence for Idiomatic Java
import java.io.Serializable; *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
import javax.persistence.Basic; * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
import javax.persistence.Column; */
import javax.persistence.Entity; package org.hibernate.test.mapping.hhh14276.entity;
import javax.persistence.Id;
import javax.persistence.IdClass; import java.io.Serializable;
import javax.persistence.Table;
import javax.persistence.Basic;
@Entity import javax.persistence.Column;
@Table(name = "\"Scores\"") import javax.persistence.Entity;
@IdClass(ScoreId.class) import javax.persistence.Id;
public class Score implements Serializable import javax.persistence.IdClass;
{ import javax.persistence.Table;
private static final long serialVersionUID = 1L;
@Entity
@Id @Table(name = "\"Scores\"")
@Column(name = "game_id") @IdClass(ScoreId.class)
private Integer gameId; public class Score implements Serializable {
@Id @Id
@Column(name = "is_home") @Column(name = "game_id")
private Boolean home; private Integer gameId;
@Basic(optional = false) @Id
@Column(name = "roster_id") @Column(name = "is_home")
private Integer rosterId; private Boolean home;
@Basic @Basic(optional = false)
@Column(name = "final_score") @Column(name = "roster_id")
private Integer finalScore; private Integer rosterId;
public Score() @Basic
{ @Column(name = "final_score")
} private Integer finalScore;
public Integer getGameId() public Score() {
{ }
return gameId;
} public Integer getGameId() {
return gameId;
public void setGameId(Integer gameId) }
{
this.gameId = gameId; public void setGameId(Integer gameId) {
} this.gameId = gameId;
}
public Boolean getHome()
{ public Boolean getHome() {
return home; return home;
} }
public void setHome(Boolean home) public void setHome(Boolean home) {
{ this.home = home;
this.home = home; }
}
public Integer getRosterId() {
public Integer getRosterId() return rosterId;
{ }
return rosterId;
} public void setRosterId(Integer rosterId) {
this.rosterId = rosterId;
public void setRosterId(Integer rosterId) }
{
this.rosterId = rosterId; public Integer getFinalScore() {
} return finalScore;
}
public Integer getFinalScore()
{ public void setFinalScore(Integer finalScore) {
return finalScore; this.finalScore = finalScore;
} }
}
public void setFinalScore(Integer finalScore)
{
this.finalScore = finalScore;
}
}

View File

@ -1,36 +1,35 @@
package org.hibernate.test.mapping.hhh14276.entity; /*
* Hibernate, Relational Persistence for Idiomatic Java
import java.io.Serializable; *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
public class ScoreId implements Serializable * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
{ */
private static final long serialVersionUID = 1L; package org.hibernate.test.mapping.hhh14276.entity;
private Integer gameId; import java.io.Serializable;
private Boolean home; public class ScoreId implements Serializable {
public ScoreId() private Integer gameId;
{
} private Boolean home;
public Integer getGameId() public ScoreId() {
{ }
return gameId;
} public Integer getGameId() {
return gameId;
public void setGameId(Integer gameId) }
{
this.gameId = gameId; public void setGameId(Integer gameId) {
} this.gameId = gameId;
}
public Boolean getHome()
{ public Boolean getHome() {
return home; return home;
} }
public void setHome(Boolean home) public void setHome(Boolean home) {
{ this.home = home;
this.home = home; }
} }
}