HHH-13266 Change test to use raw JDBC for executing native query
This commit is contained in:
parent
3fa7f197a1
commit
99a56c57d5
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.type;
|
package org.hibernate.test.type;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -155,17 +157,23 @@ public class LocalDateTimeTest extends BaseCoreFunctionalTestCase {
|
||||||
session.persist( new EntityWithLocalDateTime( 1, getExpectedLocalDateTime() ) );
|
session.persist( new EntityWithLocalDateTime( 1, getExpectedLocalDateTime() ) );
|
||||||
} );
|
} );
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
Timestamp nativeRead = (Timestamp) session.createNativeQuery(
|
session.doWork( connection -> {
|
||||||
"SELECT thevalue FROM theentity WHERE theid = :id"
|
final PreparedStatement statement = connection.prepareStatement(
|
||||||
)
|
"SELECT thevalue FROM theentity WHERE theid = ?"
|
||||||
.setParameter( "id", 1 )
|
);
|
||||||
.uniqueResult();
|
statement.setInt( 1, 1 );
|
||||||
|
statement.execute();
|
||||||
|
final ResultSet resultSet = statement.getResultSet();
|
||||||
|
resultSet.next();
|
||||||
|
Timestamp nativeRead = resultSet.getTimestamp( 1 );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Raw values written in database should match the original value (same day, hour, ...)",
|
"Raw values written in database should match the original value (same day, hour, ...)",
|
||||||
getExpectedTimestamp(), nativeRead
|
getExpectedTimestamp(),
|
||||||
|
nativeRead
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void withDefaultTimeZone(ZoneId zoneId, Runnable runnable) {
|
private static void withDefaultTimeZone(ZoneId zoneId, Runnable runnable) {
|
||||||
|
|
Loading…
Reference in New Issue