Bug 973945

Summary: EJB2 CMP entity-command is not working
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: wfink
Component: EJBAssignee: wfink
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: high    
Version: 6.1.0CC: cdewolf, jmartisk, rdickens, smumford
Target Milestone: ER3   
Target Release: EAP 6.1.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 973947 (view as bug list) Environment:
Last Closed: 2013-09-16 20:30:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 973947    

Description wfink 2013-06-13 07:25:43 UTC
Description of problem:
To use different customizations and optimizations it was possible in former version to add entity-commands to the jbosscmp-jdbc.xml DD

    <defaults>
      <entity-command name="no-select-before-insert" />
    </defaults>
    ...
    <entity>
      <ejb-name>TestEntity</ejb-name>
      ...
      <entity-command name="no-select-before-insert">

The current behaviour is that the configuration is checked (it is not possible to declare a non existing command name) but there is no effect if the entity is created at runtime.
The default command "SELECT COUNT(*)" is still executed.

Comment 1 wfink 2013-06-13 07:27:58 UTC
Looking into the JDBCCreateEntityCommand class it is extending the JDBCInsertPKCreateCommand which extends the JDBCAbstractCreateCommand.

Within JDBCInsertPKCreateCommand following lines made us looking into the details:
        if (exceptionProcessor == null) {
            initExistsSQL();
        }
		
Esp. as we do not want the exists SQL it needs to be made sure that a exceptionProcessor is set. This handling is implemented in the JDBCAbstractCreateCommand class.

With in JDBCAbstractCreateCommand class:
        JDBCEntityCommandMetaData entityCommand = manager.getMetaData().getEntityCommand();
        if (entityCommand == null) {
            throw MESSAGES.entityCommandIsNull();
        }
        initEntityCommand(entityCommand);
	
	
So, debugging in runtime shows that JDBCEntityCommandMetaData entityCommand is correctly intialized:
	[commandName=no-select-before-insert,commandClass=class org.jboss.as.cmp.jdbc.JDBCCreateEntityCommand,attributes={SQLExceptionProcessor=jboss.jdbc:service=SQLExceptionProcessor}]
	
So, then initEntityCommand(entityCommand) is called:
    protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) {
        exceptionProcessor = null;
    }
	
Here we do not understand: the exceptionProcessor is set to null (even the command has all the details) causing theat the JDBCInsertPKCreateCommand does not find the exceptionProcessor and creates an existsSQL statement - which is always fired ... even we did not want if by setting <entity-command name="no-select-before-insert" />.

Comment 6 wfink 2013-07-03 12:49:17 UTC
As this is related to a customer issue is it possible to have the solution for EAP6.1.1?

Comment 7 Jan Martiska 2013-07-26 08:09:31 UTC
Verified the fix in EAP 6.1.1.ER3.

Comment 8 Scott Mumford 2013-08-29 02:55:15 UTC
Marking for exclusion from the 6.1.1 Release Notes document as an entry for this bug could not be completed or verified in time.