Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-enabled additional tests and fix issues with IdClass
- Loading branch information
Showing
97 changed files
with
1,261 additions
and
1,296 deletions.
There are no files selected for viewing
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
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
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
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
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
66 changes: 66 additions & 0 deletions
66
hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/EnumIdTest.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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.orm.test.annotations.id; | ||
|
||
import org.hibernate.testing.TestForIssue; | ||
import org.hibernate.testing.orm.junit.DomainModel; | ||
import org.hibernate.testing.orm.junit.SessionFactory; | ||
import org.hibernate.testing.orm.junit.SessionFactoryScope; | ||
import org.hibernate.orm.test.annotations.id.entities.Planet; | ||
import org.hibernate.orm.test.annotations.id.entities.PlanetCheatSheet; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
|
||
/** | ||
* Tests for enum type as id. | ||
* | ||
* @author Hardy Ferentschik | ||
*/ | ||
@TestForIssue(jiraKey = "ANN-744") | ||
@DomainModel( | ||
annotatedClasses = PlanetCheatSheet.class | ||
) | ||
@SessionFactory | ||
public class EnumIdTest { | ||
|
||
@Test | ||
public void testEnumAsId(SessionFactoryScope scope) { | ||
PlanetCheatSheet mercury = new PlanetCheatSheet(); | ||
scope.inTransaction( | ||
session -> { | ||
mercury.setPlanet( Planet.MERCURY ); | ||
mercury.setMass( 3.303e+23 ); | ||
mercury.setRadius( 2.4397e6 ); | ||
mercury.setNumberOfInhabitants( 0 ); | ||
session.persist( mercury ); | ||
} | ||
); | ||
|
||
scope.inTransaction( | ||
session -> { | ||
PlanetCheatSheet mercuryFromDb = session.get( PlanetCheatSheet.class, mercury.getPlanet() ); | ||
assertNotNull( mercuryFromDb ); | ||
session.delete( mercuryFromDb ); | ||
} | ||
); | ||
|
||
scope.inTransaction( | ||
session -> { | ||
PlanetCheatSheet mercuryFromDb = session.get( | ||
PlanetCheatSheet.class, | ||
Planet.MERCURY | ||
); | ||
assertNull( mercuryFromDb ); | ||
} | ||
); | ||
|
||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/IdClassTest.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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.orm.test.annotations.id; | ||
|
||
import org.hibernate.testing.orm.junit.DomainModel; | ||
import org.hibernate.testing.orm.junit.SessionFactory; | ||
import org.hibernate.testing.orm.junit.SessionFactoryScope; | ||
import org.hibernate.orm.test.annotations.id.entities.Location; | ||
import org.hibernate.orm.test.annotations.id.entities.Tower; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
|
||
/** | ||
* @author Emmanuel Bernard | ||
*/ | ||
@DomainModel( | ||
annotatedClasses = Tower.class | ||
) | ||
@SessionFactory | ||
public class IdClassTest { | ||
|
||
@Test | ||
public void testIdClassInSuperclass(SessionFactoryScope scope) { | ||
Tower tower = new Tower(); | ||
tower.latitude = 10.3; | ||
tower.longitude = 45.4; | ||
|
||
scope.inTransaction( | ||
session -> { | ||
session.persist( tower ); | ||
session.flush(); | ||
session.clear(); | ||
Location loc = new Location(); | ||
loc.latitude = tower.latitude; | ||
loc.longitude = tower.longitude; | ||
assertNotNull( session.get( Tower.class, loc ) ); | ||
} | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.