@@ -43,7 +43,7 @@ public class OracleEnumTest {
4343assertEquals ( ts .activity .activityType , ActivityType .Play );
4444}
4545
46- @ Test public void testOrdinalEnum (SessionFactoryScope scope ) {
46+ @ Test public void testNamedOrdinalEnum (SessionFactoryScope scope ) {
4747Weather weather = new Weather ();
4848Sky sky = new Sky ();
4949sky .skyType = SkyType .Sunny ;
@@ -57,31 +57,62 @@ public class OracleEnumTest {
5757scope .inSession ( s -> {
5858s .doWork (
5959c -> {
60+ boolean namedEnumFound = false ;
61+ boolean namedOrdinalEnumFound = false ;
62+
6063try (Statement stmt = c .createStatement ()) {
6164try (ResultSet typeInfo = stmt .executeQuery ("select name, decode(instr(data_display,'WHEN '''),0,'NUMBER','VARCHAR2') from user_domains where type='ENUMERATED'" )) {
6265while (typeInfo .next ()) {
6366String name = typeInfo .getString (1 );
6467String baseType = typeInfo .getString (2 );
6568if (name .equalsIgnoreCase ("ActivityType" ) && baseType .equals ("VARCHAR2" )) {
66- return ;
69+ namedEnumFound = true ;
70+ continue ;
71+ }
72+ if (name .equalsIgnoreCase ("SkyType" ) && baseType .equals ("NUMBER" )) {
73+ namedOrdinalEnumFound = true ;
74+ continue ;
6775}
6876}
6977}
7078}
71- fail ("named enum type not exported" );
79+
80+ if (!namedEnumFound ) {
81+ fail ("named enum type not exported" );
82+ }
83+ if (!namedOrdinalEnumFound ) {
84+ fail ("named ordinal enum type not exported" );
85+ }
7286}
7387);
7488});
7589scope .inSession ( s -> {
7690s .doWork (
7791c -> {
92+ boolean namedEnumFound = false ;
93+ boolean namedOrdinalEnumFound = false ;
94+
7895ResultSet tableInfo = c .getMetaData ().getColumns (null , null , "ACTIVITY" , "ACTIVITYTYPE" );
7996while ( tableInfo .next () ) {
8097String type = tableInfo .getString (6 );
8198assertEquals ( "VARCHAR2" , type );
82- return ;
99+ namedEnumFound = true ;
100+ break ;
101+ }
102+ tableInfo = c .getMetaData ().getColumns (null , null , "SKY" , "SKYTYPE" );
103+ while ( tableInfo .next () ) {
104+ String type = tableInfo .getString (6 );
105+ assertEquals ( "NUMBER" , type );
106+ namedOrdinalEnumFound = true ;
107+ break ;
108+ }
109+
110+ if (!namedEnumFound ) {
111+ fail ("named enum type not exported" );
112+ }
113+ if (!namedOrdinalEnumFound ) {
114+ fail ("named ordinal enum type not exported" );
83115}
84- fail ("named enum column not exported" );
85116}
86117);
87118});
0 commit comments