[JIRA] (HHH-16661) Filters causes NPE when default schema is set
by Jones (JIRA)
Jones ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWJkMThkODEz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16661?atlOrigin=eyJpIjoiOWJkMT... ) HHH-16661 ( https://hibernate.atlassian.net/browse/HHH-16661?atlOrigin=eyJpIjoiOWJkMT... ) Filters causes NPE when default schema is set ( https://hibernate.atlassian.net/browse/HHH-16661?atlOrigin=eyJpIjoiOWJkMT... )
Change By: Jones ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I am just reusing the same test case for [https://hibernate.atlassian.net/browse/HHH-16435|https://hibernate.atlass...]
If I add {{configuration.setProperty(AvailableSettings.DEFAULT_SCHEMA, "PUBLIC"); }}we always get a NPE
{noformat}@Entity
@Table(name = "ENTITY_A")
@DiscriminatorColumn(name = "DISC_COL", discriminatorType = DiscriminatorType.INTEGER)
@FilterDef(name = "DUMMY_FILTER", defaultCondition = "(ID IS NOT NULL)")
@Filter(name = "DUMMY_FILTER")
public abstract class AbstractEntityA {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
Integer id;
}{noformat}
{noformat}@Entity
@DiscriminatorValue("1")
public class EntityAChildOne extends AbstractEntityA {}{noformat}
{noformat}@Entity
@DiscriminatorValue("2")
public class EntityAChildTwo extends AbstractEntityA {}{noformat}
{noformat} @Override
protected void configure(Configuration configuration) {
super.configure(configuration);
configuration.setProperty(AvailableSettings.SHOW_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.DEFAULT_SCHEMA, "PUBLIC");
}
@Test
public void hhhXXXXTest() throws Exception {
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
EntityAChildOne entityAChildOne = new EntityAChildOne();
EntityAChildTwo entityAChildTwo = new EntityAChildTwo();
s.persist(entityAChildOne);
s.persist(entityAChildTwo);
tx.commit();
}
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
s.enableFilter("DUMMY_FILTER");
MutationQuery deleteQuery = s.createMutationQuery("delete from org.hibernate.bugs.EntityAChildTwo");
int actual = deleteQuery.executeUpdate();
assertThat(actual).isEqualTo(1);
tx.commit();
Query<AbstractEntityA> query = s.createQuery("select c from org.hibernate.bugs.AbstractEntityA c",
AbstractEntityA.class);
List<AbstractEntityA> actualList = query.list();
assertThat(actualList).hasSize(1);
}
}{noformat}
{noformat}Hibernate:
delete
from
PUBLIC.ENTITY_A
where
DISC_COL=2
and (
ID IS NOT NULL
){noformat}
{noformat}java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.findEntityDescriptor(MappingMetamodelImpl.java:411)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.registerEntityNameUsage(BaseSqmToSqlAstConverter.java:2973)
at org.hibernate.internal.FilterHelper.render(FilterHelper.java:232)
at org.hibernate.internal.FilterHelper.generateFilterPredicate(FilterHelper.java:180)
at org.hibernate.internal.FilterHelper.applyEnabledFilters(FilterHelper.java:158)
at org.hibernate.persister.entity.AbstractEntityPersister.applyFilterRestrictions(AbstractEntityPersister.java:3042)
at org.hibernate.persister.entity.AbstractEntityPersister.applyBaseRestrictions(AbstractEntityPersister.java:3059)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.consumeFromClauseRoot(BaseSqmToSqlAstConverter.java:2776)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.hibernate.query.sqm.tree.from.SqmFromClause.visitRoots(SqmFromClause.java:80)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitFromClause(BaseSqmToSqlAstConverter.java:2542)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:2028)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:433)
at org.hibernate.query.sqm.tree.select.SqmQuerySpec.accept(SqmQuerySpec.java:122)
at org.hibernate.query.sqm.spi.BaseSemanticQueryWalker.visitQueryPart(BaseSemanticQueryWalker.java:221)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQueryPart(BaseSqmToSqlAstConverter.java:1890)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:1575)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:433)
at org.hibernate.query.sqm.tree.select.SqmSelectStatement.accept(SqmSelectStatement.java:222)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.translate(BaseSqmToSqlAstConverter.java:768)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:344)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:267)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:243)
at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:518)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:367)
at org.hibernate.bugs.ORMUnitTestCase.hhh16435Test(ORMUnitTestCase.java:85)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:833)
{noformat}
If I need to use Filters and a default schema, I see not workaround for this issue.
I’ll attach please find the modified test case for this specific issue attached and also available at [https://github.com/ratoaq2/HHH-16661|https://github.com/ratoaq2/HHH-16661...]
( https://hibernate.atlassian.net/browse/HHH-16661#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16661#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#100225- sha1:bbd69a1 )
2 years, 11 months
[JIRA] (HHH-16650) Loss in precision due usage of Float data type instead of BigDecimal in case Oracle JDBC driver returning -127 for scale and 0 for precision if precision/scale is unknown. Might happen unexpectedly and requires very close inspection of used SQL
by Gavin King (JIRA)
Gavin King ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-16650 ( https://hibernate.atlassian.net/browse/HHH-16650?atlOrigin=eyJpIjoiOTg3Yz... )
Re: Loss in precision due usage of Float data type instead of BigDecimal in case Oracle JDBC driver returning -127 for scale and 0 for precision if precision/scale is unknown. Might happen unexpectedly and requires very close inspection of used SQL ( https://hibernate.atlassian.net/browse/HHH-16650?atlOrigin=eyJpIjoiOTg3Yz... )
Well, this is one of my pet topics:
* global GDP is 10^14^ dollars but I’m pretty sure we can’t estimate it to the nearest dollar, nor even to the nearest million dollars (nor even to the nearest billion)
* the most precise clock on earth has an accuracy of something like 1 part in 10^18^ but more typical atomic clocks are more like 1 part in 10^12^
* the unix epoch in microseconds has 16 digits
* the most accurately-measured quantity in physics is known to about 12 or 13 decimal places … other quantities in the natural sciences are known to far less precision
* LIGO can measure some crazily tiny displacements but that doesn’t mean it measures them with a huge amount of precision (TBF, I’m not sure how precise the measurements are)
Anyway, the point is that when someone who works in software tells me they need a 38 decimal digits to represent their numbers, I’m a bit skeptical 🙂
Yes, OK, fine, so UUIDs have more “digits” than that, but they’re not numbers, they’re strings, and they’re by nature very wasteful.
( https://hibernate.atlassian.net/browse/HHH-16650#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16650#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#100225- sha1:bbd69a1 )
2 years, 11 months
[JIRA] (HHH-16661) Filters causes NPE when default schema is set
by Jones (JIRA)
Jones ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDRhZjA2ZWVj... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16661?atlOrigin=eyJpIjoiZDRhZj... ) HHH-16661 ( https://hibernate.atlassian.net/browse/HHH-16661?atlOrigin=eyJpIjoiZDRhZj... ) Filters causes NPE when default schema is set ( https://hibernate.atlassian.net/browse/HHH-16661?atlOrigin=eyJpIjoiZDRhZj... )
Issue Type: Bug Affects Versions: 6.2.3 Assignee: Unassigned Components: query-hql Created: 22/May/2023 00:40 AM Priority: Blocker Reporter: Jones ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I am just reusing the same test case for https://hibernate.atlassian.net/browse/HHH-16435
If I add {{configuration.setProperty(AvailableSettings.DEFAULT_SCHEMA, "PUBLIC"); }}we always get a NPE
@Entity
@Table(name = "ENTITY_A")
@DiscriminatorColumn(name = "DISC_COL", discriminatorType = DiscriminatorType.INTEGER)
@FilterDef(name = "DUMMY_FILTER", defaultCondition = "(ID IS NOT NULL)")
@Filter(name = "DUMMY_FILTER")
public abstract class AbstractEntityA {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
Integer id;
}
@Entity
@DiscriminatorValue("1")
public class EntityAChildOne extends AbstractEntityA {}
@Entity
@DiscriminatorValue("2")
public class EntityAChildTwo extends AbstractEntityA {}
@Override
protected void configure(Configuration configuration) {
super.configure(configuration);
configuration.setProperty(AvailableSettings.SHOW_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.DEFAULT_SCHEMA, "PUBLIC");
}
@Test
public void hhhXXXXTest() throws Exception {
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
EntityAChildOne entityAChildOne = new EntityAChildOne();
EntityAChildTwo entityAChildTwo = new EntityAChildTwo();
s.persist(entityAChildOne);
s.persist(entityAChildTwo);
tx.commit();
}
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
s.enableFilter("DUMMY_FILTER");
MutationQuery deleteQuery = s.createMutationQuery("delete from org.hibernate.bugs.EntityAChildTwo");
int actual = deleteQuery.executeUpdate();
assertThat(actual).isEqualTo(1);
tx.commit();
Query<AbstractEntityA> query = s.createQuery("select c from org.hibernate.bugs.AbstractEntityA c",
AbstractEntityA.class);
List<AbstractEntityA> actualList = query.list();
assertThat(actualList).hasSize(1);
}
}
Hibernate:
delete
from
PUBLIC.ENTITY_A
where
DISC_COL=2
and (
ID IS NOT NULL
)
java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.findEntityDescriptor(MappingMetamodelImpl.java:411)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.registerEntityNameUsage(BaseSqmToSqlAstConverter.java:2973)
at org.hibernate.internal.FilterHelper.render(FilterHelper.java:232)
at org.hibernate.internal.FilterHelper.generateFilterPredicate(FilterHelper.java:180)
at org.hibernate.internal.FilterHelper.applyEnabledFilters(FilterHelper.java:158)
at org.hibernate.persister.entity.AbstractEntityPersister.applyFilterRestrictions(AbstractEntityPersister.java:3042)
at org.hibernate.persister.entity.AbstractEntityPersister.applyBaseRestrictions(AbstractEntityPersister.java:3059)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.consumeFromClauseRoot(BaseSqmToSqlAstConverter.java:2776)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.hibernate.query.sqm.tree.from.SqmFromClause.visitRoots(SqmFromClause.java:80)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitFromClause(BaseSqmToSqlAstConverter.java:2542)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:2028)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:433)
at org.hibernate.query.sqm.tree.select.SqmQuerySpec.accept(SqmQuerySpec.java:122)
at org.hibernate.query.sqm.spi.BaseSemanticQueryWalker.visitQueryPart(BaseSemanticQueryWalker.java:221)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQueryPart(BaseSqmToSqlAstConverter.java:1890)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:1575)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:433)
at org.hibernate.query.sqm.tree.select.SqmSelectStatement.accept(SqmSelectStatement.java:222)
at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.translate(BaseSqmToSqlAstConverter.java:768)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:344)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:267)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:243)
at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:518)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:367)
at org.hibernate.bugs.ORMUnitTestCase.hhh16435Test(ORMUnitTestCase.java:85)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:833)
If I need to use Filters and a default schema, I see not workaround for this issue.
I’ll attach the modified test case for this specific issue
( https://hibernate.atlassian.net/browse/HHH-16661#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16661#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#100225- sha1:bbd69a1 )
2 years, 11 months