Hibernate 6 native IDENTITY

Hi,

@GeneratedValue(strategy = GenerationType.IDENTITY) was working fine with hibernate 5 + same jdbc (exasol). Now I got a strange error from driver:
com.exasol.jdbc.NotImplemented: Feature not supported - Auto-generated keys.

Old v5 was calling back:

public String getIdentitySelectString(String table, String column, int type) throws MappingException {
		return "SELECT COLUMN_IDENTITY FROM EXA_ALL_COLUMNS WHERE COLUMN_NAME='"+column.toUpperCase() +
				"' AND COLUMN_SCHEMA='"+table.substring(0, table.indexOf(".")).toUpperCase() +
				"' AND COLUMN_TABLE='"+(table.substring(table.indexOf(".")+1)).toUpperCase()+"'";

	}

Old v5 had GeneratorClass in Dialect file, and this used to work for simple logging inserts:

@Override
public Class getNativeIdentifierGeneratorClass() { return SequenceGenerator.class; }

reworked for v6:

public jakarta.persistence.GenerationType getNativeIdentifierGenerationType() {
    return GenerationType.SEQUENCE;
}

Also tried with GenerationType.IDENTITY

The v5 logs told: “Inserting entity SecurityLog (native id)” - just after “ActionQueue - Executing identity-insert immediately”.
Now v6 fails just next to “ActionQueue - Executing identity-insert immediately”:

2023-09-14 22:03:45.836 [http-nio-8080-exec-3] DEBUG o.h.SQL - insert into security_log (email,id_result,ip_address,logon_date) values (?,?,?,?)
Hibernate: insert into security_log (email,id_result,ip_address,logon_date) values (?,?,?,?)
2023-09-14 22:03:45.838 [http-nio-8080-exec-3] WARN  c.z.h.p.ProxyConnection - HikariPool-1 - Connection com.exasol.jdbc.EXAConnection@1b5a23ad marked as broken because of SQLSTATE(0A000), ErrorCode(0)
com.exasol.jdbc.NotImplemented: Feature not supported - Auto-generated keys.

and not mentioning “native”.

The Dialect no longer having sequence related supportsFns.

public boolean supportsPooledSequences() { return true; }

public boolean supportsSequences() {return false;}

I hope you guys will have any idea how to trigger native IDENTITY at database.

thx

Identity column support is defined through the #getIdentityColumnSupport() method and the IdentityColumnSupport interface. Similarly, sequence support is defined through the #getSequenceSupport(), #getQuerySequencesString() and #getSequenceInformationExtractor() methods. Finally, the strategy to choose for native identifier generation is defined with #getNativeIdentifierGeneratorStrategy().

I suggest you look at how other dialects that are already implemented in Hibernate ORM manage that to figure out how to port it to your case.

thanks all of your help. At this stage I have a version of custom exasol dialect for hb6. The issue with IDENTITY not resolved. Fyi: same exasol-jdbc 7.1.20 with HB5, does not complain against “Unsupported - AutoKeys”.

Can you please link me with custom dialect team, or may I ask you to pass the two easy files to them to review?
How can I provide the two exasol dialect files (Dialect and IdentityColumnSupport)? (22K in a ZIP file)

many thanks,
Zol

You can create a pull request for integrating the dialect into the hibernate-community-dialects module and we’ll merge it if it compiles fine, but IMO it would be best if you talk to Exasol directly about this and make sure they maintain the dialect for you since you seem to be a customer of their product.

hi, thanks for hints and ideas. At this stage I have also contacted to Exasol, and got an in general we are looking after kind of reply, and a warning the exasol-hibernate GIT project is not supported. But I still hope they will look after as a I have also sent them the reworked Dialect files. So not sure, what to expect. Let’s wait bit, and if no exa contact, then I pass you guys the code if you want to include.
cheers

1 Like

Hi,

this is what I get back from support after a month:

Blockquote
I wish I had better news for you, as I asked many teams, but, alas, there is no current Hibernate support. It was an experiment of the Sales Engineering team and has not been maintained, so it remains a legacy, as-is.
Blockquote

So, my understanding Exasol will never take care of Hibernate 6+ (springboot 3+).

The dialect I have made is working fine (99%), except one thing auto generated Id is no longer working as used to be by Hibernate5. I am pulling ids from ALL_COLUMNS object (filtered by TABLE_NAME), as earlier hibernate 5 did automatically.

The module itself is compiling, just works fine with that one limitation to grab the new id in advance of a store.

What is my next step to provide to community to dialect? I do not have GIT access to your repo. Can I send java source files to someone?

thanks

Fork the hibernate-orm repository and do your changes on a branch. Finally create a Pull Request.