From f9cce5a76742262cc2fadd9d978d06628338d783 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Mon, 16 Nov 2020 12:07:42 +0000 Subject: [PATCH] HHH-14276 Amend style and formatting --- .../NestedIdClassDerivedIdentifiersTest.java | 107 +++++------ .../mapping/hhh14276/entity/PlayerStat.java | 171 +++++++++--------- .../mapping/hhh14276/entity/PlayerStatId.java | 109 ++++++----- .../test/mapping/hhh14276/entity/Score.java | 151 ++++++++-------- .../test/mapping/hhh14276/entity/ScoreId.java | 71 ++++---- 5 files changed, 296 insertions(+), 313 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/NestedIdClassDerivedIdentifiersTest.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/NestedIdClassDerivedIdentifiersTest.java index 895aa3552f..229d9073ec 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/NestedIdClassDerivedIdentifiersTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/NestedIdClassDerivedIdentifiersTest.java @@ -1,53 +1,54 @@ -package org.hibernate.test.mapping.hhh14276; - -import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; - -import java.util.Map; - -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy; -import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; -import org.hibernate.test.mapping.hhh14276.entity.PlayerStat; -import org.hibernate.test.mapping.hhh14276.entity.Score; -import org.hibernate.testing.TestForIssue; -import org.junit.Before; -import org.junit.Test; - -/** - * This template demonstrates how to develop a test case for Hibernate ORM, using the Java Persistence API. - */ -@TestForIssue( jiraKey = "HHH-14276" ) -public class NestedIdClassDerivedIdentifiersTest extends BaseEntityManagerFunctionalTestCase -{ - @Override - protected Class[] getAnnotatedClasses() - { - return new Class[] { PlayerStat.class, - Score.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 testNestedIdClassDerivedIdentifiers() throws Exception - { - doInJPA( this::entityManagerFactory, em -> - { - // do nothing - }); - } -} \ No newline at end of file +/* + * 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 . + */ +package org.hibernate.test.mapping.hhh14276; + +import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; + +import java.util.Map; + +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy; +import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; + +import org.hibernate.test.mapping.hhh14276.entity.PlayerStat; +import org.hibernate.test.mapping.hhh14276.entity.Score; +import org.hibernate.testing.TestForIssue; +import org.junit.Before; +import org.junit.Test; + +@TestForIssue(jiraKey = "HHH-14276") +public class NestedIdClassDerivedIdentifiersTest extends BaseEntityManagerFunctionalTestCase { + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + PlayerStat.class, + Score.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 testNestedIdClassDerivedIdentifiers() { + doInJPA( this::entityManagerFactory, em -> + { + // do nothing + } ); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStat.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStat.java index a958e71078..48fe1dc884 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStat.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStat.java @@ -1,89 +1,82 @@ -package org.hibernate.test.mapping.hhh14276.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(PlayerStatId.class) -public class PlayerStat 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 Score score; - - public PlayerStat() - { - } - - public Integer getGameId() - { - return score.getGameId(); - } - - public void setGameId(Integer gameId) - { - score.setGameId(gameId); - } - - public Boolean getHome() - { - return score.getHome(); - } - - public void setHome(Boolean home) - { - score.setHome(home); - } - - 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 Score getScore() - { - return score; - } - - public void setScore(Score score) - { - this.score = score; - } -} +/* + * 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 . + */ +package org.hibernate.test.mapping.hhh14276.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(PlayerStatId.class) +public class PlayerStat implements Serializable { + + @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 Score score; + + public PlayerStat() { + } + + public Integer getGameId() { + return score.getGameId(); + } + + public void setGameId(Integer gameId) { + score.setGameId( gameId ); + } + + public Boolean getHome() { + return score.getHome(); + } + + public void setHome(Boolean home) { + score.setHome( home ); + } + + 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 Score getScore() { + return score; + } + + public void setScore(Score score) { + this.score = score; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStatId.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStatId.java index 8b967ab7e2..0b7b3455c7 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStatId.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStatId.java @@ -1,57 +1,52 @@ -package org.hibernate.test.mapping.hhh14276.entity; - -import java.io.Serializable; - -public class PlayerStatId implements Serializable -{ - private static final long serialVersionUID = 1L; - - private Integer playerId; - - // nested composite PK @IdClass: named like relationship in entity class - private ScoreId score; - - public PlayerStatId() - { - } - - public Integer getGameId() - { - return score.getGameId(); - } - - public void setGameId(Integer gameId) - { - score.setGameId(gameId); - } - - public Boolean getHome() - { - return score.getHome(); - } - - public void setHome(Boolean home) - { - score.setHome(home); - } - - public Integer getPlayerId() - { - return playerId; - } - - public void setPlayerId(Integer playerId) - { - this.playerId = playerId; - } - - public ScoreId getScoreId() - { - return score; - } - - public void setScoreId(ScoreId scoreId) - { - this.score = scoreId; - } -} +/* + * 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 . + */ +package org.hibernate.test.mapping.hhh14276.entity; + +import java.io.Serializable; + +public class PlayerStatId implements Serializable { + + private Integer playerId; + + // nested composite PK @IdClass: named like relationship in entity class + private ScoreId score; + + public PlayerStatId() { + } + + public Integer getGameId() { + return score.getGameId(); + } + + public void setGameId(Integer gameId) { + score.setGameId( gameId ); + } + + public Boolean getHome() { + return score.getHome(); + } + + public void setHome(Boolean home) { + score.setHome( home ); + } + + public Integer getPlayerId() { + return playerId; + } + + public void setPlayerId(Integer playerId) { + this.playerId = playerId; + } + + public ScoreId getScoreId() { + return score; + } + + public void setScoreId(ScoreId scoreId) { + this.score = scoreId; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/Score.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/Score.java index df589ecbf9..5c03991752 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/Score.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/Score.java @@ -1,78 +1,73 @@ -package org.hibernate.test.mapping.hhh14276.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(ScoreId.class) -public class Score 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 Score() - { - } - - 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; - } -} +/* + * 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 . + */ +package org.hibernate.test.mapping.hhh14276.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(ScoreId.class) +public class Score implements Serializable { + + @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 Score() { + } + + 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; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/ScoreId.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/ScoreId.java index 135f2f03d2..4b7e6d2162 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/ScoreId.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/ScoreId.java @@ -1,36 +1,35 @@ -package org.hibernate.test.mapping.hhh14276.entity; - -import java.io.Serializable; - -public class ScoreId implements Serializable -{ - private static final long serialVersionUID = 1L; - - private Integer gameId; - - private Boolean home; - - public ScoreId() - { - } - - 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; - } -} +/* + * 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 . + */ +package org.hibernate.test.mapping.hhh14276.entity; + +import java.io.Serializable; + +public class ScoreId implements Serializable { + + private Integer gameId; + + private Boolean home; + + public ScoreId() { + } + + 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; + } +}