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

org.hibernate.exception.GenericJDBCException: Unable to extract generated-keys ResultSet #963

Closed
McBluna opened this issue Aug 30, 2023 · 7 comments
Labels
question Further information is requested

Comments

@McBluna
Copy link

McBluna commented Aug 30, 2023

Describe the bug
While my application is trying to save the first entity to sqlite dabase, the exception occurs. Never happened before, and this was the only change in my latest build. After switching back to 3.42.0.1 it's working again.

To Reproduce
Sorry, but I have no idea

Expected behavior
3.43.0.0 should behave like 3.42.0.1 😉

Logs

2023-08-30 20:30:03,537 ALL  : org.hibernate.exception.GenericJDBCException: Unable to extract generated-keys ResultSet [not implemented by SQLite JDBC driver] [insert into "CAST_INFO" ("D_ID","ADULT","BELONG","CAST_ID","CHARACTER","CREDIT_ID","DATA_TYPE","GENDER","LOAD","NAME","_order","PROFILE_PATH","TMDB_ID") values (?,?,?,?,?,?,?,?,?,?,?,?,?)]
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:61)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.id.insert.GetGeneratedKeysDelegate.performInsert(GetGeneratedKeysDelegate.java:139)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.engine.jdbc.mutation.internal.MutationExecutorPostInsertSingleTable.execute(MutationExecutorPostInsertSingleTable.java:101)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.persister.entity.mutation.InsertCoordinator.doStaticInserts(InsertCoordinator.java:169)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.persister.entity.mutation.InsertCoordinator.coordinateInsert(InsertCoordinator.java:111)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2757)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:674)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:291)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:272)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:322)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:363)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:277)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:140)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:175)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.DefaultPersistEventListener.persist(DefaultPersistEventListener.java:93)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:77)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:54)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:755)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:739)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.hibernate.v4243.CastInfoDAO.save(CastInfoDAO.java:40)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.db.DBFactoryV4243.save(DBFactoryV4243.java:490)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.HomeTheaterDB.save(HomeTheaterDB.java:1487)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.lambda$createCastInfo$1(NFO.java:226)
2023-08-30 20:30:03,537 ALL  : 	at java.base/java.util.ArrayList.forEach(Unknown Source)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.createCastInfo(NFO.java:219)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.updateMovieInfo(NFO.java:643)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.processMovie(NFO.java:1327)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.insertMovie(NFO.java:1257)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.lambda$call$9(NFO.java:1661)
2023-08-30 20:30:03,537 ALL  : 	at java.base/java.lang.Iterable.forEach(Unknown Source)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.NFO.call(NFO.java:1642)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.config.NfoCommand.call(NfoCommand.java:470)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.config.NfoCommand.call(NfoCommand.java:25)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine.access$1500(CommandLine.java:148)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
2023-08-30 20:30:03,537 ALL  : 	at picocli.CommandLine.execute(CommandLine.java:2170)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.HomeTheater.execute(HomeTheater.java:93)
2023-08-30 20:30:03,537 ALL  : 	at net.mcbluna.zidoo.HomeTheater.main(HomeTheater.java:138)
2023-08-30 20:30:03,537 ALL  : Caused by: java.sql.SQLFeatureNotSupportedException: not implemented by SQLite JDBC driver
2023-08-30 20:30:03,537 ALL  : 	at org.sqlite.jdbc3.JDBC3PreparedStatement.unsupported(JDBC3PreparedStatement.java:448)
2023-08-30 20:30:03,537 ALL  : 	at org.sqlite.jdbc3.JDBC3Statement.getGeneratedKeys(JDBC3Statement.java:357)
2023-08-30 20:30:03,537 ALL  : 	at org.hibernate.id.insert.GetGeneratedKeysDelegate.performInsert(GetGeneratedKeysDelegate.java:110)
2023-08-30 20:30:03,537 ALL  : 	... 44 more

Environment (please complete the following information):

  • OS: Windows 11
  • CPU architecture: x86_64
  • sqlite-jdbc version 3.43.0.0

Additional context
My application is updating a SQLite database from an Android based media player.

@McBluna McBluna added the triage label Aug 30, 2023
@McBluna
Copy link
Author

McBluna commented Aug 30, 2023

Oh, maybe I should have read the release log for 3.43.0.0 before 🤦‍♂️

🚨 remove support for Statement#getGeneratedKeys: getGeneratedKeys is not supported anymore

Any suggestion what I've to change in my code to not use getGeneratedKeys?

@McBluna
Copy link
Author

McBluna commented Aug 30, 2023

From what I see, I've to change how hibernates handles the getGeneratedKeys stuff.
My code uses persist on session to save entity.

public void save(final CastInfo transientInstance) {
	if (LOG.isDebugEnabled()) {
		LOG.debug("saving CastInfo instance");
	}
	try {
		getSession().persist(transientInstance);
		if (LOG.isDebugEnabled()) {
			LOG.debug("save successful");
		}
	} catch (final RuntimeException re) {
		if (LOG.isErrorEnabled()) {
			LOG.error("save failed", re);
		}
		throw re;
	}
}

@gotson
Copy link
Collaborator

gotson commented Aug 31, 2023

Any suggestion what I've to change in my code to not use getGeneratedKeys?

You should use https://www.sqlite.org/lang_returning.html

@gotson gotson added question Further information is requested triage and removed triage labels Aug 31, 2023
@gotson gotson pinned this issue Aug 31, 2023
@gotson gotson removed the triage label Aug 31, 2023
@McBluna McBluna closed this as completed Aug 31, 2023
@sproket
Copy link

sproket commented Sep 4, 2023

Is the returning clause supported on older releases of sqlite?

@McBluna
Copy link
Author

McBluna commented Sep 4, 2023

It is supported until version 3.42.0.1.

@gotson
Copy link
Collaborator

gotson commented Sep 5, 2023

Is the returning clause supported on older releases of sqlite?

The RETURNING syntax has been supported by SQLite since version 3.35.0 (2021-03-12).

@clragon
Copy link

clragon commented Dec 1, 2023

You should use https://www.sqlite.org/lang_returning.html

It seems like Kotlin Exposed does not support RETURNING so I am just left without a good solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants