-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-14276 Amend style and formatting
- Loading branch information
Showing
5 changed files
with
296 additions
and
313 deletions.
There are no files selected for viewing
107 changes: 54 additions & 53 deletions
107
...rc/test/java/org/hibernate/test/mapping/hhh14276/NestedIdClassDerivedIdentifiersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); | ||
} | ||
} | ||
/* | ||
* 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; | ||
|
||
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 | ||
} ); | ||
} | ||
} |
171 changes: 82 additions & 89 deletions
171
hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
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; | ||
} | ||
} |
109 changes: 52 additions & 57 deletions
109
hibernate-core/src/test/java/org/hibernate/test/mapping/hhh14276/entity/PlayerStatId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
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; | ||
} | ||
} |
Oops, something went wrong.