[JIRA] (HHH-14069) LazyLoad with singleTable inheritance don't use discriminatorValue
by Florian Kern (JIRA)
Florian Kern ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ee102c... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjA2MjAzZTQ0... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14069?atlOrigin=eyJpIjoiZjA2Mj... ) HHH-14069 ( https://hibernate.atlassian.net/browse/HHH-14069?atlOrigin=eyJpIjoiZjA2Mj... ) LazyLoad with singleTable inheritance don't use discriminatorValue ( https://hibernate.atlassian.net/browse/HHH-14069?atlOrigin=eyJpIjoiZjA2Mj... )
Issue Type: Bug Affects Versions: 5.4.17 Assignee: Unassigned Components: hibernate-core, hibernate-entitymanager Created: 12/Jun/2020 02:45 AM Priority: Critical Reporter: Florian Kern ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ee102c... )
see the attached test case, In later situations a org.hibernate.WrongClassException is thrown, because of in the first loaded Collection are a wrong mapped object.
org.hibernate.WrongClassException: Object [id=1] was not of the specified subclass [eu.pinske.model.Child2] : loaded object was of wrong class class eu.pinske.model.Child1
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.hydrateEntityState(EntityReferenceInitializerImpl.java:195)
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:109)
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:124)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:105)
at org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:87)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:710)
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:76)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:2161)
at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:589)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:264)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:585)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:149)
at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:188)
at eu.pinske.test.ThingTest.test(ThingTest.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
( https://hibernate.atlassian.net/browse/HHH-14069#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14069#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#100128- sha1:14a4bff )
5 years, 10 months
[JIRA] (HHH-14067) Hibernate SchemaUpdate improve drop constraint
by Petar Tahchiev (JIRA)
Petar Tahchiev ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjNhYjg5OWU5... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYj... ) HHH-14067 ( https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYj... ) Hibernate SchemaUpdate improve drop constraint ( https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYj... )
Issue Type: Bug Affects Versions: 5.4.15 Assignee: Unassigned Created: 11/Jun/2020 09:53 AM Priority: Major Reporter: Petar Tahchiev ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Hello,
we are using the Hibernate SchemaUpdate to create an SQL file like this:
final SchemaUpdate schemaUpdate = new SchemaUpdate();
schemaUpdate.setDelimiter(schemaProperties.getDelimiter());
schemaUpdate.setFormat(schemaProperties.getFormat());
schemaUpdate.setOutputFile(getHibernateScriptOutputFilename(database, true ));
schemaUpdate.execute(EnumSet.of(TargetType.SCRIPT), getHibernateConfiguration(database, null ));
which works fine unless when there's a new table. When we have a new table, the new SQL file created is the following:
create table external_care_product (
DTYPE varchar(31) not null ,
id bigint not null ,
code varchar(255) not null ,
created_by varchar(255),
created_date datetime,
last_modified_by varchar(255),
last_modified_date datetime,
external_service_id varchar(255),
external_service_name varchar(255),
external_service_provider varchar(255),
care_product_id bigint,
primary key (id)
) engine=InnoDB;
alter table external_care_product
drop constraint UK_c91alca5s7iub60faehho1u54;
alter table external_care_product
add constraint UK_c91alca5s7iub60faehho1u54 unique (code);
Notice that it first drops the constraint and then creates the constraint. So whenever we try to execute this script to the DB it fails because the constraint it tries to drop doesn't exist. Would it be possible to use something like "alter table drop constraint if exists"? If not then I think it's more appropriate to skip the drop part.
( https://hibernate.atlassian.net/browse/HHH-14067#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14067#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#100128- sha1:3143c77 )
5 years, 10 months