-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
124 additions
and
140 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
73 changes: 73 additions & 0 deletions
73
hibernate-core/src/test/java/org/hibernate/orm/test/type/OracleNamedEnumTest.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,73 @@ | ||
/* | ||
* 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.type; | ||
|
||
import org.hibernate.dialect.OracleDialect; | ||
import org.hibernate.testing.orm.junit.RequiresDialect; | ||
import org.hibernate.testing.orm.junit.SessionFactoryScope; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
import java.util.Locale; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
@RequiresDialect(value = OracleDialect.class, majorVersion = 23) | ||
public class OracleNamedEnumTest extends AbstractNamedEnumTest { | ||
|
||
@Override | ||
protected String normalizeNameForQueryingMetadata(String name) { | ||
return name.toUpperCase(Locale.ROOT); | ||
} | ||
|
||
@Override | ||
protected String getDataTypeForNamedEnum(String namedEnum) { | ||
return "VARCHAR2"; | ||
} | ||
|
||
@Override | ||
protected String getDataTypeForNamedOrdinalEnum(String namedEnum) { | ||
return "NUMBER"; | ||
} | ||
|
||
@Test public void testUserDomains(SessionFactoryScope scope) { | ||
scope.inSession( s -> { | ||
s.doWork( | ||
c -> { | ||
boolean namedEnumFound = false; | ||
boolean namedOrdinalEnumFound = false; | ||
|
||
try(Statement stmt = c.createStatement()) { | ||
try(ResultSet typeInfo = stmt.executeQuery("select name, decode(instr(data_display,'WHEN '''),0,'NUMBER','VARCHAR2') from user_domains where type='ENUMERATED'")) { | ||
while (typeInfo.next()) { | ||
String name = typeInfo.getString(1); | ||
String baseType = typeInfo.getString(2); | ||
if (name.equalsIgnoreCase("ActivityType") && baseType.equals( | ||
getDataTypeForNamedEnum("ActivityType"))) { | ||
namedEnumFound = true; | ||
continue; | ||
} | ||
if (name.equalsIgnoreCase("SkyType") && baseType.equals( | ||
getDataTypeForNamedOrdinalEnum("SkyType"))) { | ||
namedOrdinalEnumFound = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!namedEnumFound) { | ||
fail("named enum type not exported"); | ||
} | ||
if (!namedOrdinalEnumFound) { | ||
fail("named ordinal enum type not exported"); | ||
} | ||
} | ||
); | ||
}); | ||
} | ||
} |
90 changes: 0 additions & 90 deletions
90
hibernate-core/src/test/java/org/hibernate/orm/test/type/PostgresEnumTest.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
hibernate-core/src/test/java/org/hibernate/orm/test/type/PostgresNamedEnumTest.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,26 @@ | ||
package org.hibernate.orm.test.type; | ||
|
||
import java.util.Locale; | ||
|
||
import org.hibernate.dialect.PostgreSQLDialect; | ||
import org.hibernate.testing.orm.junit.RequiresDialect; | ||
|
||
@RequiresDialect(PostgreSQLDialect.class) | ||
public class PostgresNamedEnumTest extends AbstractNamedEnumTest { | ||
|
||
@Override | ||
protected String normalizeNameForQueryingMetadata(String name) { | ||
return name.toLowerCase(Locale.ROOT); | ||
} | ||
|
||
@Override | ||
protected String getDataTypeForNamedEnum(String namedEnum) { | ||
return namedEnum.toLowerCase(Locale.ROOT); | ||
} | ||
|
||
@Override | ||
protected String getDataTypeForNamedOrdinalEnum(String namedEnum) { | ||
return namedEnum.toLowerCase(Locale.ROOT); | ||
} | ||
|
||
} |