[hibernate-issues] [JIRA] (HHH-13939) H2Dialect @GeneratedValue regression on schema generation, uses sequence instead of generated by default as identity

IT Support (JIRA) jira at hibernate.atlassian.net
Tue Apr 7 16:42:45 EDT 2020


IT Support ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A7c7fc415-3805-43c8-9dfa-7cbe1117db94 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2E3MDE1OWE4MWI3NDlkZTlkMjdkMjEwZjgxMjUyODgiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13939?atlOrigin=eyJpIjoiN2E3MDE1OWE4MWI3NDlkZTlkMjdkMjEwZjgxMjUyODgiLCJwIjoiaiJ9 ) HHH-13939 ( https://hibernate.atlassian.net/browse/HHH-13939?atlOrigin=eyJpIjoiN2E3MDE1OWE4MWI3NDlkZTlkMjdkMjEwZjgxMjUyODgiLCJwIjoiaiJ9 ) H2Dialect @GeneratedValue regression on schema generation, uses sequence instead of generated by default as identity ( https://hibernate.atlassian.net/browse/HHH-13939?atlOrigin=eyJpIjoiN2E3MDE1OWE4MWI3NDlkZTlkMjdkMjEwZjgxMjUyODgiLCJwIjoiaiJ9 )

Change By: IT Support ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A7c7fc415-3805-43c8-9dfa-7cbe1117db94 )

In Hibernate 4.x, specifically 4.3.11 , all worked as expected.

{code:xml|title= * persistence.xml snippet } *

{code:xml} <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:unittests" />
{code}

{code:sql|title= * 4.x generated SQL } *
Hibernate
{code : sql} create table dbo.office (officeid bigint generated by default as identity, office varchar(255) not null, description varchar(255), sequence varchar(255), orgid bigint not null, primary key (officeid))
{code}
{code:sql|title=
In 5.x the DB structure has changed in incompatible ways.

*5.x generated SQL } *

{code:sql} create table dbo.office (officeid bigint not null, office varchar(255) not null, description varchar(255), sequence varchar(255), orgid bigint not null, primary key (officeid))

create sequence hibernate_sequence start with 1 increment by 1
{code}

I have confirmed the dialect values are sensible. The error seems to be inside / around the  {{  SessionFactoryImpl  }}  's  {{  identifierGenerators  }} . While the dialect indicates Identity generation, the generator seems to be a result of  {{  DefaultIdentifierGeneratorFactory  }}  , which produces sequence based ids.

Specifically the  {{  metadata.getEntityBindings()  }}  returns a  {{  PersistentClass  }}  model where the identifier is a  {{  SimpleValue  }}  whose  {{  identifierGenerator  }}  is a  {{  SequenceStyleGenerator  }} .

This can be backtracked to:

*EntityManagerFactoryBuilderImpl*

{code:java |title=EntityManagerFactoryBuilderImpl }
private MetadataImplementor metadata() {
if ( this.metadata == null ) {
this.metadata = MetadataBuildingProcess.complete( managedResources, metamodelBuilder.getMetadataBuildingOptions() );
}
return metadata;
}
{code}

This is not related to:

* [ HHH-13727 ]
* [ HHH-13597 ]

( https://hibernate.atlassian.net/browse/HHH-13939#add-comment?atlOrigin=eyJpIjoiN2E3MDE1OWE4MWI3NDlkZTlkMjdkMjEwZjgxMjUyODgiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13939#add-comment?atlOrigin=eyJpIjoiN2E3MDE1OWE4MWI3NDlkZTlkMjdkMjEwZjgxMjUyODgiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:c13ca0d )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200407/3699fc75/attachment.html 


More information about the hibernate-issues mailing list