[JIRA] (HHH-15718) Polymorphic queries with condition do not work
by Alex Karki (JIRA)
Alex Karki ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=632b44a... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDVmN2ZkOTVm... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15718?atlOrigin=eyJpIjoiZDVmN2... ) HHH-15718 ( https://hibernate.atlassian.net/browse/HHH-15718?atlOrigin=eyJpIjoiZDVmN2... ) Polymorphic queries with condition do not work ( https://hibernate.atlassian.net/browse/HHH-15718?atlOrigin=eyJpIjoiZDVmN2... )
Issue Type: Bug Affects Versions: 6.1.5 Assignee: Unassigned Components: query-hql Created: 14/Nov/2022 18:53 PM Environment: - pure 'org.hibernate:hibernate-core:6.1.5.Final'
- JDK: Temurin-17.0.4.1+1
- Windows 10
- MySQL 5.7.39
- 'mysql:mysql-connector-java:5.1.46'
- XML mapping
Priority: Major Reporter: Alex Karki ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=632b44a... )
When a query uses an interface name instead of a class name, it is not possible to use that object in "where" condition. For example, all these queries do work in Hibernate 5.6 and fail in 6.1:
final String [] queries = {
"from " + I. class. getName(),
"from " + I. class. getName() + " where displayName is null " ,
"from " + I. class. getName() + " i" ,
"from " + I. class. getName() + " i where i.displayName is null " ,
"select i from " + I. class. getName() + " i" ,
"select i from " + I. class. getName() + " i where i.displayName is null " ,
"select displayName from " + I. class. getName(),
"select i.displayName from " + I. class. getName() + " i" ,
"select i.displayName from " + I. class. getName() + " i where i.displayName is null " ,
};
for ( String query : queries) {
try ( final var session = sessionFactory.openSession()) {
session.createQuery(query).list();
}
}
The exception is
jakarta.persistence.PersistenceException: Converting `org.hibernate.sql.ast.SqlTreeCreationException` to JPA `PersistenceException` : Could not locate TableGroup - model.I(396480023707500)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:374)
at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:1032)
Mapped via XML:
public interface I {
String getDisplayName();
}
public class A implements I {
private Long id;
private String displayName;
...
}
public class B implements I {
private Long id;
private String displayName;
...
}
<hibernate-mapping> <class name= "model.A" table= "A" > <id name= "id" type= "long" column= "id" > <generator class= "native" /> </id> <property name= "displayName" type= "string" column= "display_name" /> </class> </hibernate-mapping>
( https://hibernate.atlassian.net/browse/HHH-15718#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15718#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#100210- sha1:583150f )
1 year, 10 months
[JIRA] (HHH-15717) SQL script executed twice when using persistence.xml jakarta.persistence.sql-load-script-source property
by Scott Marlow (JIRA)
Scott Marlow ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjY0NGEwYjZh... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15717?atlOrigin=eyJpIjoiZjY0NG... ) HHH-15717 ( https://hibernate.atlassian.net/browse/HHH-15717?atlOrigin=eyJpIjoiZjY0NG... ) SQL script executed twice when using persistence.xml jakarta.persistence.sql-load-script-source property ( https://hibernate.atlassian.net/browse/HHH-15717?atlOrigin=eyJpIjoiZjY0NG... )
Issue Type: Bug Affects Versions: 6.1.3 Assignee: Unassigned Created: 14/Nov/2022 12:08 PM Environment: To build wildfly locally (note the `wildfly-28.0.0.Beta1-SNAPSHOT` reference may need to change to a newer WF release):
git clone https://github.com/wildfly/wildfly/ ( https://github.com/wildfly/wildfly/ )
cd wildfly
./build.sh clean install -DskipTests=true
cd dist/target/wildfly-28.0.0.Beta1-SNAPSHOT/bin
./standalone.sh
git clone https://github.com/emmartins/quickstart/ ( https://github.com/emmartins/quickstart/ )
cd quickstart/kitchensink
git checkout sqlscriptruntwice
mvn clean install wildfly:deploy
Priority: Major Reporter: Scott Marlow ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
As per https://issues.redhat.com/browse/WFLY-16864 ( https://issues.redhat.com/browse/WFLY-16864 ) , the https://github.com/emmartins/quickstart/tree/sqlscriptruntwice ( https://github.com/emmartins/quickstart/tree/sqlscriptruntwice ) (kitchensink folder) contains a test that when run against WildFly with Hibernate ORM 6.1.5.Final (or earlier 6.x ORM releases), will reproduce the failure mentioned in WFLY-16864
14:56:42,852 INFO [org.hibernate.tool.schema.internal.SchemaCreatorImpl] (ServerService Thread Pool -- 87) HHH000476: Executing import script 'vfs:/content/kitchensink.war/WEB-INF/classes/import.sql'
14:56:42,854 INFO [org.hibernate.tool.schema.internal.SchemaCreatorImpl] (ServerService Thread Pool -- 87) HHH000476: Executing import script 'vfs:/content/kitchensink.war/WEB-INF/classes/import.sql'
14:56:42,856 WARN [org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl] (ServerService Thread Pool -- 87) GenerationTarget encountered exception accepting command : Error executing DDL "insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith(a)mailinator.com', '2125551212')" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith(a)mailinator.com', '2125551212')" via JDBC Statement
The first run of the database script is from https://github.com/hibernate/hibernate-orm/blob/09299e1f417a193dabf0e020f... ( https://github.com/hibernate/hibernate-orm/blob/09299e1f417a193dabf0e020f... ) and the second is from https://github.com/hibernate/hibernate-orm/blob/09299e1f417a193dabf0e020f... ( https://github.com/hibernate/hibernate-orm/blob/09299e1f417a193dabf0e020f... )
I just reproduced this again but didn’t verify that the same lines of code are reached.
( https://hibernate.atlassian.net/browse/HHH-15717#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15717#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#100210- sha1:583150f )
1 year, 10 months