HHH-14276 Amend style and formatting

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

View File

@ -1,3 +1,9 @@
/*
* 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.hhh14276; package org.hibernate.test.mapping.hhh14276;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -7,47 +13,42 @@ import java.util.Map;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy; import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.test.mapping.hhh14276.entity.PlayerStat; import org.hibernate.test.mapping.hhh14276.entity.PlayerStat;
import org.hibernate.test.mapping.hhh14276.entity.Score; import org.hibernate.test.mapping.hhh14276.entity.Score;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/** @TestForIssue(jiraKey = "HHH-14276")
* This template demonstrates how to develop a test case for Hibernate ORM, using the Java Persistence API. public class NestedIdClassDerivedIdentifiersTest extends BaseEntityManagerFunctionalTestCase {
*/ @Override
@TestForIssue( jiraKey = "HHH-14276" ) protected Class<?>[] getAnnotatedClasses() {
public class NestedIdClassDerivedIdentifiersTest extends BaseEntityManagerFunctionalTestCase return new Class<?>[] {
{ PlayerStat.class,
@Override Score.class
protected Class<?>[] getAnnotatedClasses() };
{ }
return new Class<?>[] { PlayerStat.class,
Score.class };
}
@Override @Override
protected void addConfigOptions( Map options ) protected void addConfigOptions(Map options) {
{ options.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, Boolean.TRUE );
options.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, Boolean.TRUE ); options.put( AvailableSettings.HQL_BULK_ID_STRATEGY, InlineIdsOrClauseBulkIdStrategy.class.getName() );
options.put( AvailableSettings.HQL_BULK_ID_STRATEGY, InlineIdsOrClauseBulkIdStrategy.class.getName() ); }
}
@Before @Before
public void setUp() public void setUp() {
{ doInJPA( this::entityManagerFactory, em ->
doInJPA( this::entityManagerFactory, em -> {
{ // do nothing
// do nothing } );
} ); }
}
@Test @Test
public void testNestedIdClassDerivedIdentifiers() throws Exception public void testNestedIdClassDerivedIdentifiers() {
{ doInJPA( this::entityManagerFactory, em ->
doInJPA( this::entityManagerFactory, em -> {
{ // do nothing
// do nothing } );
}); }
}
} }

View File

@ -1,3 +1,9 @@
/*
* 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.hhh14276.entity; package org.hibernate.test.mapping.hhh14276.entity;
import java.io.Serializable; import java.io.Serializable;
@ -15,75 +21,62 @@ import javax.persistence.Table;
@Entity @Entity
@Table(name = "\"PlayerStats\"") @Table(name = "\"PlayerStats\"")
@IdClass(PlayerStatId.class) @IdClass(PlayerStatId.class)
public class PlayerStat implements Serializable public class PlayerStat implements Serializable {
{
private static final long serialVersionUID = 1L;
@Id @Id
@Column(name = "player_id") @Column(name = "player_id")
private Integer playerId; private Integer playerId;
@Basic(optional = false) @Basic(optional = false)
@Column(name = "jersey_nbr") @Column(name = "jersey_nbr")
private Integer jerseyNbr; private Integer jerseyNbr;
@Id @Id
@ManyToOne(optional = false, fetch = FetchType.EAGER) @ManyToOne(optional = false, fetch = FetchType.EAGER)
@JoinColumn(name = "game_id", referencedColumnName = "game_id") @JoinColumn(name = "game_id", referencedColumnName = "game_id")
@JoinColumn(name = "is_home", referencedColumnName = "is_home") @JoinColumn(name = "is_home", referencedColumnName = "is_home")
private Score score; private Score score;
public PlayerStat() public PlayerStat() {
{ }
}
public Integer getGameId() public Integer getGameId() {
{ return score.getGameId();
return score.getGameId(); }
}
public void setGameId(Integer gameId) public void setGameId(Integer gameId) {
{ score.setGameId( 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) public void setPlayerId(Integer playerId) {
{ this.playerId = playerId;
this.playerId = playerId; }
}
public Integer getJerseyNbr() public Integer getJerseyNbr() {
{ return jerseyNbr;
return jerseyNbr; }
}
public void setJerseyNbr(Integer jerseyNbr) public void setJerseyNbr(Integer jerseyNbr) {
{ this.jerseyNbr = jerseyNbr;
this.jerseyNbr = jerseyNbr; }
}
public Score getScore() public Score getScore() {
{ return score;
return score; }
}
public void setScore(Score score) public void setScore(Score score) {
{ this.score = score;
this.score = score; }
}
} }

View File

@ -1,57 +1,52 @@
/*
* 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.hhh14276.entity; package org.hibernate.test.mapping.hhh14276.entity;
import java.io.Serializable; import java.io.Serializable;
public class PlayerStatId implements Serializable public class PlayerStatId implements Serializable {
{
private static final long serialVersionUID = 1L;
private Integer playerId; private Integer playerId;
// nested composite PK @IdClass: named like relationship in entity class // nested composite PK @IdClass: named like relationship in entity class
private ScoreId score; private ScoreId score;
public PlayerStatId() public PlayerStatId() {
{ }
}
public Integer getGameId() public Integer getGameId() {
{ return score.getGameId();
return score.getGameId(); }
}
public void setGameId(Integer gameId) public void setGameId(Integer gameId) {
{ score.setGameId( 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) public void setPlayerId(Integer playerId) {
{ this.playerId = playerId;
this.playerId = playerId; }
}
public ScoreId getScoreId() public ScoreId getScoreId() {
{ return score;
return score; }
}
public void setScoreId(ScoreId scoreId) public void setScoreId(ScoreId scoreId) {
{ this.score = scoreId;
this.score = scoreId; }
}
} }

View File

@ -1,3 +1,9 @@
/*
* 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.hhh14276.entity; package org.hibernate.test.mapping.hhh14276.entity;
import java.io.Serializable; import java.io.Serializable;
@ -12,67 +18,56 @@ import javax.persistence.Table;
@Entity @Entity
@Table(name = "\"Scores\"") @Table(name = "\"Scores\"")
@IdClass(ScoreId.class) @IdClass(ScoreId.class)
public class Score implements Serializable public class Score implements Serializable {
{
private static final long serialVersionUID = 1L;
@Id @Id
@Column(name = "game_id") @Column(name = "game_id")
private Integer gameId; private Integer gameId;
@Id @Id
@Column(name = "is_home") @Column(name = "is_home")
private Boolean home; private Boolean home;
@Basic(optional = false) @Basic(optional = false)
@Column(name = "roster_id") @Column(name = "roster_id")
private Integer rosterId; private Integer rosterId;
@Basic @Basic
@Column(name = "final_score") @Column(name = "final_score")
private Integer finalScore; private Integer finalScore;
public Score() public Score() {
{ }
}
public Integer getGameId() public Integer getGameId() {
{ return gameId;
return gameId; }
}
public void setGameId(Integer gameId) public void setGameId(Integer gameId) {
{ this.gameId = 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) public void setRosterId(Integer rosterId) {
{ this.rosterId = rosterId;
this.rosterId = rosterId; }
}
public Integer getFinalScore() public Integer getFinalScore() {
{ return finalScore;
return finalScore; }
}
public void setFinalScore(Integer finalScore) public void setFinalScore(Integer finalScore) {
{ this.finalScore = finalScore;
this.finalScore = finalScore; }
}
} }

View File

@ -1,36 +1,35 @@
/*
* 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.hhh14276.entity; package org.hibernate.test.mapping.hhh14276.entity;
import java.io.Serializable; import java.io.Serializable;
public class ScoreId implements Serializable public class ScoreId implements Serializable {
{
private static final long serialVersionUID = 1L;
private Integer gameId; private Integer gameId;
private Boolean home; private Boolean home;
public ScoreId() public ScoreId() {
{ }
}
public Integer getGameId() public Integer getGameId() {
{ return gameId;
return gameId; }
}
public void setGameId(Integer gameId) public void setGameId(Integer gameId) {
{ this.gameId = 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; }
}
} }