[JIRA] (HHH-17065) Column ordering leads to wrong column order in composite primary keys
by Benedikt Waldvogel (JIRA)
Benedikt Waldvogel ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYmQzYjFkYTIz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-17065?atlOrigin=eyJpIjoiYmQzYj... ) HHH-17065 ( https://hibernate.atlassian.net/browse/HHH-17065?atlOrigin=eyJpIjoiYmQzYj... ) Column ordering leads to wrong column order in composite primary keys ( https://hibernate.atlassian.net/browse/HHH-17065?atlOrigin=eyJpIjoiYmQzYj... )
Issue Type: Bug Affects Versions: 6.2.7 Assignee: Unassigned Created: 09/Aug/2023 13:16 PM Priority: Major Reporter: Benedikt Waldvogel ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Note: This issue is very similar to https://hibernate.atlassian.net/browse/HHH-16943 but the same problem happens for *composite primary keys*.
-----
Given
-----
@Entity
@IdClass( CompositePrimaryKey.class )
static class TestEntity {
@Id private String b;
@Id private String a;
}
private static class CompositePrimaryKey {
private String b;
private String a;
// getters, setters, hashCode, equals
}
Note that we define the composite primary key on the columns *(b, a)* (in that very order). The column order could be important since the underlying primary key index should be used to speed-up queries that select all entities for a given value of “b”.
-------------------
Actual vs. Expected
-------------------
When the schema gets created in the context of a JPA EntityManagerFactory, the columns are (re-)ordered during construction of the SessionFactoryImpl, Line 252: bootMetamodel.orderColumns( false ) ( https://github.com/hibernate/hibernate-orm/blob/58aff00957721074a4a393725... )
This leads to the following DDL:
create table "TestEntity" (
a varchar (255) not null ,
b varchar (255) not null ,
primary key ( a , b)
)
Note that the primary key is created for *(a, b)* instead of the expected column order *(b, a)*.
----------
Workaround
----------
One can restore the behavior of Hibernate 6.1 by switching to the legacy column ordering strategy via hibernate.column_ordering_strategy=legacy.
---------
Test Case
---------
Upcoming…
( https://hibernate.atlassian.net/browse/HHH-17065#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-17065#add-comment?atlOrigin=ey... )
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.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100234- sha1:90f5128 )
1 year, 1 month
[JIRA] (HHH-17064) Fetch mode select causes StackOverflowError
by Ruslan Gryn (JIRA)
Ruslan Gryn ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNGVjNjcyZjMz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-17064?atlOrigin=eyJpIjoiNGVjNj... ) HHH-17064 ( https://hibernate.atlassian.net/browse/HHH-17064?atlOrigin=eyJpIjoiNGVjNj... ) Fetch mode select causes StackOverflowError ( https://hibernate.atlassian.net/browse/HHH-17064?atlOrigin=eyJpIjoiNGVjNj... )
Issue Type: Bug Affects Versions: 6.2.7 Assignee: Unassigned Attachments: orm.zip Components: hibernate-core Created: 09/Aug/2023 13:15 PM Environment: PostgreSQL
h2 Priority: Major Reporter: Ruslan Gryn ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I discovered this issue during migration to Spring Boot 3 and Hibernate 6.2
So if we have the following entity
@Entity
public class Main {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
private Connector connector;
@ManyToOne(fetch = FetchType.LAZY)
private Sub sub;
}
This entity has a reference to Sub entity which is lazy
Connector entity has a reference on Sub as well and FetchMode is a SELECT
@Entity
public class Connector {
@Id
private Long id;
@ManyToOne
@Fetch(FetchMode.SELECT)
private Sub sub;
}
when executing the following query select m from Main m where m.connector.id = 1 you will get the following exception
ava.lang.StackOverflowError
at org.hibernate.sql.results.graph.entity.EntityInitializer.findFirstEntityInitializer(EntityInitializer.java:34)
at org.hibernate.sql.results.graph.entity.internal.EntitySelectFetchInitializerBuilder.createInitializer(EntitySelectFetchInitializerBuilder.java:45)
at org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl.buildEntitySelectFetchInitializer(EntityFetchSelectImpl.java:92)
at org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl.lambda$createAssembler$0(EntityFetchSelectImpl.java:70)
at org.hibernate.sql.results.internal.ResultsHelper$1.resolveInitializer(ResultsHelper.java:117)
at org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl.createAssembler(EntityFetchSelectImpl.java:67)
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.<init>(AbstractEntityInitializer.java:172)
at org.hibernate.sql.results.graph.entity.internal.EntityJoinedFetchInitializer.<init>(EntityJoinedFetchInitializer.java:48)
at org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl.buildEntityJoinedFetchInitializer(EntityFetchJoinedImpl.java:127)
at org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl.lambda$getEntityInitializer$0(EntityFetchJoinedImpl.java:100)
at org.hibernate.sql.results.internal.ResultsHelper$1.resolveInitializer(ResultsHelper.java:117)
at org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl.getEntityInitializer(EntityFetchJoinedImpl.java:97)
at org.hibernate.sql.results.graph.entity.AbstractNonLazyEntityFetch.createAssembler(AbstractNonLazyEntityFetch.java:68)
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.<init>(AbstractEntityInitializer.java:172)
at org.hibernate.sql.results.graph.entity.internal.EntityResultInitializer.<init>(EntityResultInitializer.java:35)
at org.hibernate.sql.results.graph.entity.internal.EntityResultImpl.lambda$createResultAssembler$0(EntityResultImpl.java:91)
at org.hibernate.sql.results.internal.ResultsHelper$1.resolveInitializer(ResultsHelper.java:117)
at org.hibernate.sql.results.graph.entity.internal.EntityResultImpl.createResultAssembler(EntityResultImpl.java:82)
at org.hibernate.sql.results.jdbc.internal.StandardJdbcValuesMapping.resolveAssemblers(StandardJdbcValuesMapping.java:53)
I’ve attached the reproducer. Run ORMStandaloneTestCase class to reproduce this issue
Also, it works fine on Hibernate 5
( https://hibernate.atlassian.net/browse/HHH-17064#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-17064#add-comment?atlOrigin=ey... )
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.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100234- sha1:90f5128 )
1 year, 1 month
[JIRA] (HHH-17063) Exceptions while running junit tests after migrating to hibernate 6.1 and spring boot 3
by Harika Chepuri (JIRA)
Harika Chepuri ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNGFkMDNmYzk4... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-17063?atlOrigin=eyJpIjoiNGFkMD... ) HHH-17063 ( https://hibernate.atlassian.net/browse/HHH-17063?atlOrigin=eyJpIjoiNGFkMD... ) Exceptions while running junit tests after migrating to hibernate 6.1 and spring boot 3 ( https://hibernate.atlassian.net/browse/HHH-17063?atlOrigin=eyJpIjoiNGFkMD... )
Issue Type: Bug Assignee: Unassigned Created: 09/Aug/2023 09:55 AM Priority: Major Reporter: Harika Chepuri ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... )
ava.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@1783503a testClass = com.abc.apps.cfc.admin.controller.ContentRepositoryControllerTest, locations = [], classes = [com.abc.apps.cfc.admin.CaseAdminApplication] , contextInitializerClasses = [], activeProfiles = [], propertySourceLocations = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"] , contextCustomizers = [[ImportsContextCustomizer@68be4514 key = [@org.springframework.security.test.context.support.WithMockUser(password="password", value="user", setupBefore=TEST_METHOD, authorities={}, username="admin", roles=
{"application_admin"}
), @org.springframework.test.context.BootstrapWith(org.springframework.boot.test.context.SpringBootTestContextBootstrapper.class), @org.springframework.boot.autoconfigure.EnableAutoConfiguration(excludeName={}, exclude={}), @org.springframework.boot.test.context.SpringBootTest(args={}, webEnvironment=MOCK, useMainMethod=NEVER, value={}, properties={}, classes={}), @org.springframework.context.annotation.Import(
{org.springframework.boot.autoconfigure.AutoConfigurationPackages$Registrar.class}
), @org.springframework.boot.autoconfigure.AutoConfigurationPackage(basePackages={}, basePackageClasses={}), @org.springframework.security.test.context.support.WithSecurityContext(setupBefore=TEST_METHOD, factory=org.springframework.security.test.context.support.WithMockUserSecurityContextFactory.class), @jakarta.transaction.Transactional(value=REQUIRED, rollbackOn={}, dontRollbackOn={}), @org.springframework.context.annotation.Import(
{org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.class}
)]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@710c2b53, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7ce026d3, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@73553422, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@25be7b63, org.springframework.boot.test.web.reactive.server.WebTestClientContextCustomizer@c430e6c, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@9da1, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@3cce5371, org.springframework.boot.test.context.SpringBootTestAnnotation@c5922b90], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:142)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:127)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:191)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:130)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:241)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [TenantPersistentConfig.class] : [PersistenceUnit: persistent-unit] Unable to build Hibernate SessionFactory; nested exception is java.lang.IllegalStateException: PostInitCallback queue could not be processed...
* PostInitCallbackEntry - Entity(Recipient) sqmMultiTableMutationStrategy interpretation
* PostInitCallbackEntry - Entity(Recipient) sqmMultiTableInsertStrategy interpretation
* PostInitCallbackEntry - Entity(Reminder) sqmMultiTableMutationStrategy interpretation
* PostInitCallbackEntry - Entity(Reminder) sqmMultiTableInsertStrategy interpretation
( https://hibernate.atlassian.net/browse/HHH-17063#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-17063#add-comment?atlOrigin=ey... )
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.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100234- sha1:90f5128 )
1 year, 1 month
[JIRA] (HHH-17062) When hibernate.ddl-auto is update, it keeps on altering MEDIUMTEXT and Date and DateTime defintions
by Archimedes Trajano (JIRA)
Archimedes Trajano ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-17062 ( https://hibernate.atlassian.net/browse/HHH-17062?atlOrigin=eyJpIjoiY2U5MD... )
Re: When hibernate.ddl-auto is update, it keeps on altering MEDIUMTEXT and Date and DateTime defintions ( https://hibernate.atlassian.net/browse/HHH-17062?atlOrigin=eyJpIjoiY2U5MD... )
My guess is in MySQLDialect
private final SizeStrategy sizeStrategy = new SizeStrategyImpl() {
@Override
public Size resolveSize(
JdbcType jdbcType,
JavaType<?> javaType,
Integer precision,
Integer scale,
Long length) {
switch ( jdbcType.getDdlTypeCode() ) {
case Types.BIT:
// MySQL allows BIT with a length up to 64 (less the default length 255)
if ( length != null ) {
return Size.length( Math.min( Math.max( length, 1 ), 64 ) );
}
case Types.DATE:
return Size.length(10);
case Types.TIMESTAMP:
// if DATETIME(0) ... not sure show to determine this
return Size.length(19);
// if DATETIME(1) ... not sure show to determine this
return Size.length(??); // likely a different size
...
}
return super.resolveSize( jdbcType, javaType, precision, scale, length );
}
};
( https://hibernate.atlassian.net/browse/HHH-17062#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-17062#add-comment?atlOrigin=ey... )
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.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100234- sha1:90f5128 )
1 year, 1 month