[JIRA] (HSEARCH-4811) Automated code formatting
by Yoann Rodière (JIRA)
Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate Search ( https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiYTNmMjcw... ) / Task ( https://hibernate.atlassian.net/browse/HSEARCH-4811?atlOrigin=eyJpIjoiYTN... ) HSEARCH-4811 ( https://hibernate.atlassian.net/browse/HSEARCH-4811?atlOrigin=eyJpIjoiYTN... ) Automated code formatting ( https://hibernate.atlassian.net/browse/HSEARCH-4811?atlOrigin=eyJpIjoiYTN... )
Issue Type: Task Assignee: Unassigned Components: build Created: 02/Mar/2023 23:51 PM Fix Versions: 6.2-backlog Priority: Major Reporter: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
In Quarkus for example, the build is set up to:
* check formatting and imports very strictly on compilation
* auto-format code and auto-sort imports on request (on process-sources )
This has benefits (very consistent style) and drawbacks (annoying build failures just because of formatting), but since we already enforce a (rather loose) style, I thing we could benefit from the same approach.
Introducing tooling wouldn’t be a problem, we just have to copy what’s been done on Quarkus, replacing the Quarkus style with our own.
We will have to adapt the contribution guide as well.
The real problem will be dealing with Git history, since I expect a big commit that will reformat almost every file in the code base. Maybe we should introduce a file listing all commits to ignore in git-blame, as explained here ( https://moxio.com/blog/ignoring-bulk-change-commits-with-git-blame/#git-2... ). It would require setup on each clone ( git config ), but some setup is already required to use the proper style in Intellij, so it’s no big deal. Plus, it seems compatible with the git blame feature inside Intellij IDEA ( https://youtrack.jetbrains.com/issue/IDEA-221278 ).
NOTE: We’d better do this in a version of Hibernate Search that will not require much backports, because the “big formatting commit” will make backporting rather annoying (many conflicts).
( https://hibernate.atlassian.net/browse/HSEARCH-4811#add-comment?atlOrigin... ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-4811#add-comment?atlOrigin... )
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#100217- sha1:65be9f2 )
1 year, 10 months
[JIRA] (HHH-16247) Criteria Query with Object-Typed Embedded Parameter throws AssertionError
by Nicolas Noffke (JIRA)
Nicolas Noffke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a9bd36... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMTU4MTZhYWIy... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16247?atlOrigin=eyJpIjoiMTU4MT... ) HHH-16247 ( https://hibernate.atlassian.net/browse/HHH-16247?atlOrigin=eyJpIjoiMTU4MT... ) Criteria Query with Object-Typed Embedded Parameter throws AssertionError ( https://hibernate.atlassian.net/browse/HHH-16247?atlOrigin=eyJpIjoiMTU4MT... )
Change By: Nicolas Noffke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a9bd36... )
The following criteria query where the Parameter’s type is Object and the value is an Embedded throws an AssertionError. If the parameter is correctly typed it works. For the Object type Parameter, querying for a simple value like a string also works.
{code:java}final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<WithEmbedded> query = cb.createQuery(WithEmbedded.class);
final Root<WithEmbedded> root = query.from(WithEmbedded.class);
//deliberately using Object type here, using AnEmbeddable works
final ParameterExpression<Object> parameter = cb.parameter(Object.class);
query.select(root).where(cb.equal(root.get("e"), parameter));
final TypedQuery<WithEmbedded> typedQuery = entityManager.createQuery(query);
typedQuery.setParameter(parameter, new AnEmbeddable("a", "b"));
typedQuery.getResultList(); //throws AssertionError{code}
{code:none}java.lang.AssertionError
at org.hibernate.query.sqm.internal.SqmUtil.createValueBindings(SqmUtil.java:401)
at org.hibernate.query.sqm.internal.SqmUtil.createJdbcParameterBindings(SqmUtil.java:326)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:393)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:300)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:276)
at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:571)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:363)
at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:1073)
at org.hibernate.query.Query.getResultList(Query.java:94){code}
While this might seem contrived on its own, it happens with the following spring data jpa code:
{noformat}@Embeddable
data class AnEmbeddable(@Column(nullable = false) val foo: String, @Column(nullable = false) val bar: String)
interface HasEmbeddable{
val e: AnEmbeddable
}
@Entity
class WithEmbedded(@Id val id: Long, @Embedded override val e: AnEmbeddable): HasEmbeddable
@NoRepositoryBean
interface HasEmbeddableRepository<T: HasEmbeddable, ID, in AnEmbeddable> : JpaRepository<T, ID>{
fun findByE(e: AnEmbeddable): List<WithEmbedded>
}
interface WithEmbeddedRepository: HasEmbeddableRepository<WithEmbedded, Long, AnEmbeddable>{noformat}
Please find a hibernate test here: [https://github.com/noffke/criteria-embedded-parameter-test|https://github...]
Corresponding test case for spring data: [https://github.com/noffke/spring-data-jpa-embedded-test/blob/master/src/t...]
( https://hibernate.atlassian.net/browse/HHH-16247#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16247#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#100217- sha1:65be9f2 )
1 year, 10 months
[JIRA] (HHH-16247) Criteria Query with Object-Typed Embedded Parameter throws AssertionError
by Nicolas Noffke (JIRA)
Nicolas Noffke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a9bd36... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2ExOTI5N2E3... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16247?atlOrigin=eyJpIjoiN2ExOT... ) HHH-16247 ( https://hibernate.atlassian.net/browse/HHH-16247?atlOrigin=eyJpIjoiN2ExOT... ) Criteria Query with Object-Typed Embedded Parameter throws AssertionError ( https://hibernate.atlassian.net/browse/HHH-16247?atlOrigin=eyJpIjoiN2ExOT... )
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Components: query-criteria Created: 02/Mar/2023 23:08 PM Priority: Major Reporter: Nicolas Noffke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a9bd36... )
The following criteria query where the Parameter’s type is Object and the value is an Embedded throws an AssertionError. If the parameter is correctly typed it works. For the Object type Parameter, querying for a simple value like a string also works.
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<WithEmbedded> query = cb.createQuery(WithEmbedded.class);
final Root<WithEmbedded> root = query.from(WithEmbedded.class);
//deliberately using Object type here, using AnEmbeddable works
final ParameterExpression< Object > parameter = cb.parameter( Object.class);
query.select(root).where(cb.equal(root.get( "e" ), parameter));
final TypedQuery<WithEmbedded> typedQuery = entityManager.createQuery(query);
typedQuery.setParameter(parameter, new AnEmbeddable( "a" , "b" ));
typedQuery.getResultList(); // throws AssertionError
java.lang.AssertionError
at org.hibernate.query.sqm.internal.SqmUtil.createValueBindings(SqmUtil.java:401)
at org.hibernate.query.sqm.internal.SqmUtil.createJdbcParameterBindings(SqmUtil.java:326)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:393)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:300)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:276)
at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:571)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:363)
at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:1073)
at org.hibernate.query.Query.getResultList(Query.java:94)
While this might seem contrived on its own, it happens with the following spring data code:
@Embeddable
data class AnEmbeddable(@Column(nullable = false) val foo: String, @Column(nullable = false) val bar: String)
interface HasEmbeddable{
val e: AnEmbeddable
}
@Entity
class WithEmbedded(@Id val id: Long, @Embedded override val e: AnEmbeddable): HasEmbeddable
@NoRepositoryBean
interface HasEmbeddableRepository<T: HasEmbeddable, ID, in AnEmbeddable> : JpaRepository<T, ID>{
fun findByE(e: AnEmbeddable): List<WithEmbedded>
}
interface WithEmbeddedRepository: HasEmbeddableRepository<WithEmbedded, Long, AnEmbeddable>
Please find a hibernate test here: https://github.com/noffke/criteria-embedded-parameter-test ( https://github.com/noffke/criteria-embedded-parameter-test )
Corresponding test case for spring data: https://github.com/noffke/spring-data-jpa-embedded-test/blob/master/src/t... ( https://github.com/noffke/spring-data-jpa-embedded-test/blob/master/src/t... )
( https://hibernate.atlassian.net/browse/HHH-16247#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16247#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#100217- sha1:65be9f2 )
1 year, 10 months