[Hibernate-JIRA] Created: (HHH-4964) NullPointerException instead of StaleStateException when using natural-id in mapping
by Dzmitry Petrushenka (JIRA)
NullPointerException instead of StaleStateException when using natural-id in mapping
------------------------------------------------------------------------------------
Key: HHH-4964
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4964
Project: Hibernate Core
Issue Type: Bug
Components: core
Environment: Hibernate 3.3.2.GA, DB2 UDB 9.5
Reporter: Dzmitry Petrushenka
Attachments: src.zip
Use natural-id in a mapping for Foo entity.
1. First transaction creates an instance of this entity.
2. The second transaction deletes this entity.
3. The third transaction tries to update this object.
NullPointerException happens instead of throwing StaleStateException.
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkNaturalId(DefaultFlushEntityEventListener.java:112)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:192)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at example.bug1.FooTest.main(FooTest.java:39)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 9 months
[Hibernate-JIRA] Created: (HHH-4963) Inproper separator for nested unregistered sql function
by Jürgen (JIRA)
Inproper separator for nested unregistered sql function
-------------------------------------------------------
Key: HHH-4963
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4963
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: Java version: 1.6.0_16,Sun Microsystems Inc.
Java VM: Java HotSpot(TM) 64-Bit Server VM 14.2-b01,Sun Microsystems Inc.
OS-System: Linux 2.6.25.14-69.fc8,amd64
Hibernate 3.2.4.sp1
JBosss-4.2.3.GA
DB2 v8 / JDBC Driver v4.7.85
Reporter: Jürgen
HQL query clauses:
{{column1 LIKE CONCAT(CONCAT('%', REPLACE(:matchString, '%', '%%')), '%')}}
{{column1 LIKE '%' || REPLACE(:matchString, '%', '%%') || '%'}}
translate to:
{{t0_.column1 like '%'||REPLACE(?||'%'||'%%')||'%'}}
Investigation results:
* used dialect {{org.hibernate.dialect.DB2Dialect}} does not have "{{replace}}" as a registered function.
* "{{concat}}" is registered as a {{org.hibernate.dialect.function.VarArgsSQLFunction}} with "{{||}}" separator.
* invoked render method {{org.hibernate.hql.ast.SqlGenerator.beginFunctionTemplate(AST, AST)}} does put {{org.hibernate.hql.ast.SqlGenerator.FunctionArguments}} writer on stack for outer {{concat}} method
* 2. invocation of render method {{org.hibernate.hql.ast.SqlGenerator.beginFunctionTemplate(AST, AST)}} does *NOT* put a new FunctionsArgments writer on stack, *NOR* does it put the {{org.hibernate.hql.ast.SqlGenerator.DefaultWriter}} back on the stack --> outer {{concat}} method FunctionArguments writer captures replace method call output parts as its arguments: "replace(?", "'%'", "'%%')"
suggestion: in case of {{template == null}}, let {{org.hibernate.hql.ast.SqlGenerator.beginFunctionTemplate(AST, AST)}} put a new DefaultWriter on the stack, and {{org.hibernate.hql.ast.SqlGenerator.endFunctionTemplate(AST)}} remove it again.
workaround by subclassing dialect and registering "{{replace}}" function template, but still, other unregistered functions would be treated improperly.
eclipse vardump of {{functionArgments}} on {{org.hibernate.hql.ast.SqlGenerator.endFunctionTemplate(AST)}} for {{concat}}
{code}
functionArguments org.hibernate.hql.ast.SqlGenerator$FunctionArguments (id=322)
argInd 3
args java.util.ArrayList<E> (id=336)
elementData java.lang.Object[5] (id=342)
[0] "'%'" (id=346)
[1] "REPLACE(?" (id=347)
[2] "'%'" (id=348)
[3] "'%%')" (id=350)
[4] null
modCount 4
size 4
this$0 org.hibernate.hql.ast.SqlGenerator (id=279)
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 9 months