Skip to content

Commit

Permalink
Fix a bunch of issues encountered with ORM 6
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Nov 9, 2024
1 parent ad184b3 commit 0876fab
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 143 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ None yet

### Bug fixes

None yet
* Fix missing cascading deletes for deletes that contain joins or CTEs
* Fix some issues with PostgreSQL and Oracle multiset SQL rendering with Hibernate ORM 6+
* Fix returning clause rendering for PostgreSQL with Hibernate ORM 6+

### Backwards-incompatible changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ private void renderEquality(Expression left, Expression right, boolean negated,
rewriteToIdParam(right);
}
} else {
if (expressionToSplit == null || dbmsDialect.supportsAnsiRowValueConstructor() || !(left instanceof ParameterExpression) && !(right instanceof ParameterExpression)) {
if (expressionToSplit == null || !(left instanceof ParameterExpression) && !(right instanceof ParameterExpression)) {
left.accept(this);
sb.append(operator);
if (quantifier != PredicateQuantifier.ONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
context.addChunk(postChunk);
context.addChunk(subquery.substring(fromIndex));
} else {
int limitIndex = SqlUtils.indexOfLimit(subquery, orderByIndex);
if (limitIndex == -1) {
if (SqlUtils.indexOfLimit(subquery, orderByIndex) == -1 && SqlUtils.indexOfFetchFirst(subquery, orderByIndex) == -1) {
context.addChunk(preChunk);

StringBuilder sb = new StringBuilder(fromIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
context.addChunk("))");
context.addChunk(subquery.substring(fromIndex));
} else {
int limitIndex = SqlUtils.indexOfLimit(subquery, orderByIndex);
if (limitIndex == -1) {
if (SqlUtils.indexOfLimit(subquery, orderByIndex) == -1 && SqlUtils.indexOfFetchFirst(subquery, orderByIndex) == -1) {
renderJsonObjectArguments(context, fields, selectItemExpressions);
context.addChunk("))");
context.addChunk(" OVER (");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
context.addChunk("))");
context.addChunk(subquery.substring(fromIndex));
} else {
int limitIndex = SqlUtils.indexOfLimit(subquery, orderByIndex);
if (limitIndex == -1) {
if (SqlUtils.indexOfLimit(subquery, orderByIndex) == -1 && SqlUtils.indexOfFetchFirst(subquery, orderByIndex) == -1) {
renderXmlElementArguments(context, fields, selectItemExpressions);
context.addChunk("))");
context.addChunk(" OVER (");
Expand Down
17 changes: 16 additions & 1 deletion core/testsuite-hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<module.name>com.blazebit.persistence.core.testsuite.hibernate</module.name>
<testBasePackage>com.blazebit.persistence.testsuite</testBasePackage>
<testBasePackage>com.blazebit.persistence.testsuite.hibernate</testBasePackage>
<surefireForkCount>0</surefireForkCount>
</properties>

Expand Down Expand Up @@ -634,5 +634,20 @@
</plugins>
</build>
</profile>
<profile>
<!-- No need to run this with EclipseLink -->
<id>eclipselink</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<skip>true</skip>
<skipMain>true</skipMain>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Blazebit
*/
package com.blazebit.persistence.testsuite.hibernate6.entity;
package com.blazebit.persistence.testsuite.hibernate.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Blazebit
*/
package com.blazebit.persistence.testsuite.hibernate6.entity;
package com.blazebit.persistence.testsuite.hibernate.entity;

public interface Property<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Blazebit
*/
package com.blazebit.persistence.testsuite.hibernate6.entity;
package com.blazebit.persistence.testsuite.hibernate.entity;

import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Blazebit
*/
package com.blazebit.persistence.testsuite.hibernate6.entity;
package com.blazebit.persistence.testsuite.hibernate.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.blazebit.persistence.CriteriaBuilder;
import com.blazebit.persistence.testsuite.AbstractCoreTest;
import com.blazebit.persistence.testsuite.hibernate6.entity.PropertyHolder;
import com.blazebit.persistence.testsuite.hibernate.entity.PropertyHolder;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ protected AssertStatementBuilder deleteDocumentOwned(AssertStatementBuilder buil
.assertDelete().forRelation(Document.class, "peopleListBag").and()
.assertDelete().forRelation(Document.class, "peopleCollectionBag").and();
}
if (isQueryStrategy() && !simpleDelete && dbmsDialect.supportsModificationQueryInWithClause()) {
return builder;
}
if (supportsNestedEmbeddables()) {
builder
.assertDelete().forRelation(Document.class, "nameContainerMap").and()
Expand All @@ -228,7 +231,9 @@ protected AssertStatementBuilder deletePersonOwned(AssertStatementBuilder builde
.assertDelete().forRelation(Person.class, "favoriteDocuments").and()
;
}

if (isQueryStrategy() && !simpleDelete && dbmsDialect.supportsModificationQueryInWithClause()) {
return builder;
}
return builder
.assertDelete().forRelation(Person.class, "localized").and()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder;
import com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink;
import com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate;
import com.blazebit.persistence.testsuite.entity.Document;
import com.blazebit.persistence.testsuite.entity.DocumentForSimpleOneToOne;
import com.blazebit.persistence.testsuite.entity.DocumentInfoSimple;
Expand All @@ -32,7 +33,7 @@
*/
@RunWith(Parameterized.class)
// NOTE: Hibernate has a bug when selecting inverse one-to-ones: https://hibernate.atlassian.net/browse/HHH-12885
@Category({ NoEclipselink.class})
@Category({ NoHibernate.class, NoEclipselink.class})
public class EntityViewUpdateSubviewInverseOneToOneEntityTest extends AbstractEntityViewUpdateTest<UpdatableDocumentForOneToOneView> {

private DocumentForSimpleOneToOne doc1;
Expand Down
Loading

0 comments on commit 0876fab

Please sign in to comment.