ConcurrentModificationException during schema creation

Description

java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
at java.util.HashMap$EntryIterator.next(Unknown Source)
at java.util.HashMap$EntryIterator.next(Unknown Source)
at org.hibernate.mapping.Table.cleanseUniqueKeyMap(Table.java:291)
at org.hibernate.mapping.Table.cleanseUniqueKeyMapIfNeeded(Table.java:262)
at org.hibernate.mapping.Table.getUniqueKeys(Table.java:251)
at org.hibernate.mapping.Table.getUniqueKeyIterator(Table.java:247)
at org.hibernate.mapping.Table.sqlCreateString(Table.java:530)
at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:1028)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:125)
at org.hibernate.tool.hbm2x.Hbm2DDLExporter.doStart(Hbm2DDLExporter.java:165)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:96)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)

Problematic code was introduced with
https://hibernate.atlassian.net/browse/HHH-6707#icft=HHH-6707 - One-to-One mapping with foreign key in target table and foreign key b…

Activity

Show:

Brett MeyerMarch 7, 2014 at 10:08 PM

Bulk closing tickets resolved in released versions

DamienDAugust 6, 2012 at 7:12 AM

Thanks!

Guenther DemetzJuly 20, 2012 at 10:37 AM

Functional testcase and bugfix as proposed by Steve:

https://github.com/hibernate/hibernate-orm/pull/358

Steve EbersoleJuly 19, 2012 at 2:23 PM

You sure like to argue huh? I never asked for a unit test. Yes I am well aware of the difference, believe me, I get to discuss it every few months. What I need I need and asked for is a functional test that illustrates when this occurs. You "dont have time" for that, so fine

DamienDJuly 19, 2012 at 6:51 AM

I'm pretty sure that situations like below cause it:

Site

@ManyToOne(cascade = CascadeType.ALL, optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "DEFAULT_PAYMENT_OPTION_ID")
protected PaymentOption defaultPaymentOption;

SubSite extends Site

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "site")
@Cascade({org.hibernate.annotations.CascadeType.ALL})
private Set<PaymentOption> paymentOptions;

PaymentOption

@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "SITE_ID", nullable = true)
private Site site;

Note: PaymentOption has a reference to Site but a subclass of Site (SubSite) has the reference to PaymentOption. I think hibernate generates foreign keys for both sides but they get different names.

I don't have time to setup a test case for this but a structure like above should generate the problem.

Regardless, the test case that I did write clearly shows that the code wasn't working and that once fixed works as expected. As far as unit tests go, what I provided is better than a mapping file (for testing the code in question).

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created July 12, 2012 at 3:10 PM
Updated May 5, 2022 at 10:53 AM
Resolved May 5, 2022 at 10:53 AM