Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H2: column of 'text' type requires open transaction even if it was already read successfully #848

Closed
LoneEngineer opened this issue Mar 26, 2020 · 2 comments

Comments

@LoneEngineer
Copy link

Exposed 0.22.1

there is a 'text' column in a table.
val phone = text("phone").index("phoneRequests_phone_idx")

This code works perfectly with PostgreSQL database, but end-up with exception on H2:

    fun find(session: SessionId, challenge: SmsChallenge): CallResult<....> =
        PhoneRequestRecord.safeFind(...)  {
            (sessionId eq session.sid) and (confirmationCode eq challenge.code) and (validUntil greater Instant.now())
        }.map {
            System.out.println("*** ${it.id}, ${it.appType}, ${it.validUntil}")
            System.out.println("*** ${it.id}, ${it.phone}")

where 'safeFind' is just a wrapper to represent result of transaction as Either:

transaction { Entity.find { cond } }.toEither(...)

the exception is:

2020-03-26 18:05:23.182 DEBUG [DefaultDispatcher-worker-2 @coroutine#9][][] Exposed - SELECT PHONEREQUESTS.ID, PHONEREQUESTS.PHONE, PHONEREQUESTS.SID, PHONEREQUESTS."confirmCode", PHONEREQUESTS."appName", PHONEREQUESTS."osName", PHONEREQUESTS."createTimestamp", PHONEREQUESTS."validTill" FROM PHONEREQUESTS WHERE PHONEREQUESTS.SID = '5d3a3e19045dcc85ee8b05ce1af78eb4' AND PHONEREQUESTS."confirmCode" = '000000' AND PHONEREQUESTS."validTill" > '2020-03-26T18:05:23.171392'
*** 1, Client, 2020-03-26T16:10:23.026084Z
2020-03-26 18:06:14.251 WARN  [DefaultDispatcher-worker-1 @coroutine#8][][] Exposed - Transaction attempt #0 failed: The object is already closed [90007-199]. Statement(s): null
org.h2.jdbc.JdbcSQLNonTransientException: The object is already closed [90007-199]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
	at org.h2.message.DbException.get(DbException.java:205)
	at org.h2.message.DbException.get(DbException.java:181)
	at org.h2.message.DbException.get(DbException.java:170)
	at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1568)
	at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1547)
	at org.h2.jdbc.JdbcLob.checkClosed(JdbcLob.java:99)
	at org.h2.jdbc.JdbcLob.checkReadable(JdbcLob.java:121)
	at org.h2.jdbc.JdbcLob.getCharacterStream(JdbcLob.java:169)
	at org.h2.jdbc.JdbcClob.getCharacterStream(JdbcClob.java:94)
	at org.jetbrains.exposed.sql.StringColumnType.valueFromDB(ColumnType.kt:258)
	at org.jetbrains.exposed.sql.ResultRow.rawToColumnValue(ResultRow.kt:46)
	at org.jetbrains.exposed.sql.ResultRow.get(ResultRow.kt:25)
	at org.jetbrains.exposed.dao.Entity.lookup(Entity.kt:96)
	at org.jetbrains.exposed.dao.Entity.getValue(Entity.kt:82)
	at org.jetbrains.exposed.dao.Entity.getValue(Entity.kt:117)

while debugger shows that 'phone' value is already read:
image

@LoneEngineer LoneEngineer changed the title H2: column of 'text' type requires open transaction even if it was read and mapped successfully H2: column of 'text' type requires open transaction even if it was already read successfully Mar 26, 2020
@Tapac
Copy link
Contributor

Tapac commented Apr 9, 2020

Look similar to #310 (comment)

Tapac added a commit that referenced this issue May 19, 2020
…ready read successfully #848

Eager loading for text columns
@Tapac
Copy link
Contributor

Tapac commented May 19, 2020

@LoneEngineer , eagerLoading param added to a text column to cover such cases.
Will be available in 0.24.2

@Tapac Tapac closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants