0 Replies Latest reply on Jun 17, 2006 7:24 AM by rganesan

    actual table-name is not taken while creating SQL query - ur

    rganesan

      I have a Entity bean for table name USER_INFO and the abstract-schema-name is UserBean. In the EJB-QL, I am using abstract schema name. But when the CMP plugin initialized for UserBean, it logs the equivalent SQL queries for finders in which the schema name is not substituted with atual DB table name.

      My jbosscmp-jdbc.xml is as follows.
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">

      <jbosscmp-jdbc>
      datasource/PostgresDS



      <enterprise-beans>

      <ejb-name>UserBean</ejb-name>
      datasource/PostgresDS
      <datasource-mapping>PostgreSQL</datasource-mapping>
      <table-name>USER_INFO</table-name>

      <cmp-field>
      <field-name>userId</field-name>
      <column-name>USER_ID</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>userPassword</field-name>
      <column-name>USER_PASS</column-name>

      </cmp-field>


      </enterprise-beans>
      </jbosscmp-jdbc>

      My ejb-jar.xml is

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar >

      [CDATA[No Description.]]
      <display-name>Generated by XDoclet</display-name>

      <enterprise-beans>

      <!-- Session Beans -->

      [CDATA[Description for AuthenticateDelegateBean]]
      <display-name>Name for AuthenticateDelegateBean</display-name>

      <ejb-name>AuthenticateDelegateBean</ejb-name>

      com.telepet.interfaces.AuthenticateDelegateBeanHome
      com.telepet.interfaces.AuthenticateDelegateBean
      <ejb-class>com.telepet.ejb.bl.AuthenticateDelegateBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <ejb-local-ref >
      <ejb-ref-name>ejb/UserLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.telepet.interfaces.UserBeanLocalHome</local-home>
      com.telepet.interfaces.UserBeanLocal
      <ejb-link>UserBean</ejb-link>
      </ejb-local-ref>



      <!--
      To add session beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called session-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Entity Beans -->

      [CDATA[Description for User]]
      <display-name>User Entity</display-name>

      <ejb-name>UserBean</ejb-name>

      <local-home>com.telepet.interfaces.UserBeanLocalHome</local-home>
      com.telepet.interfaces.UserBeanLocal

      <ejb-class>com.telepet.ejb.entity.user.UserBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>UserBean</abstract-schema-name>
      <cmp-field >
      [CDATA[]]
      <field-name>userId</field-name>
      </cmp-field>
      <cmp-field >
      [CDATA[]]
      <field-name>userPassword</field-name>
      </cmp-field>
      <primkey-field>userId</primkey-field>


      <query-method>
      <method-name>findByUserId</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>[CDATA[SELECT OBJECT(a) FROM UserBean AS a WHERE a.userId = ?1]]</ejb-ql>

      <!-- Write a file named ejb-finders-UserBean.xml if you want to define extra finders. -->



      <!--
      To add entity beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called entity-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Message Driven Beans -->
      <!--
      To add message driven beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called message-driven-beans.xml that contains
      the <message-driven></message-driven> markup for those beans.
      -->

      </enterprise-beans>

      <!-- Relationships -->

      <!-- Assembly Descriptor -->
      <!--
      To specify your own assembly descriptor info here, add a file to your
      XDoclet merge directory called assembly-descriptor.xml that contains
      the <assembly-descriptor></assembly-descriptor> markup.
      -->

      <assembly-descriptor >
      <!--
      To specify additional security-role elements, add a file in the merge
      directory called ejb-security-roles.xml that contains them.
      -->

      <!-- method permissions -->
      <!--
      To specify additional method-permission elements, add a file in the merge
      directory called ejb-method-permissions.ent that contains them.
      -->

      <!-- transactions -->
      <!--
      To specify additional container-transaction elements, add a file in the merge
      directory called ejb-container-transactions.ent that contains them.
      -->
      <container-transaction >

      <ejb-name>UserBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>

      <!-- finder transactions -->

      <!-- message destinations -->
      <!--
      To specify additional message-destination elements, add a file in the merge
      directory called ejb-message-destinations.ent that contains them.
      -->

      <!-- exclude list -->
      <!--
      To specify an exclude-list element, add a file in the merge directory
      called ejb-exclude-list.xml that contains it.
      -->
      </assembly-descriptor>

      </ejb-jar>

      And when this is deployed, I can see the following statements in the console. Here all the SQL query has the bean name not the actual table name. Pls help me...


      13:06:56,076 DEBUG [UserBean] Initializing CMP plugin for UserBean
      13:06:56,110 DEBUG [UserBean] Loading standardjbosscmp-jdbc.xml : file:/usr/local/jboss-4.0.4.GA/server/telepet/conf/standardjbosscmp-jdbc.xml
      13:06:56,589 DEBUG [IdleRemover] internalRegisterPool: registering pool with interval 900000 old interval: 9223372036854775807
      13:06:56,589 DEBUG [IdleRemover] internalRegisterPool: about to notify thread: old next: 1150542866589, new next: 1150542866589
      13:06:57,714 DEBUG [UserBean] Insert Entity SQL: INSERT INTO userbean (userId, userPassword) VALUES (?, ?)
      13:06:57,714 DEBUG [UserBean] Entity Exists SQL: SELECT COUNT(*) FROM userbean WHERE userId=?
      13:06:57,715 DEBUG [UserBean] entity-command: [commandName=default,commandClass=class org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand,attributes={}]
      13:06:57,722 DEBUG [UserBean] Remove SQL: DELETE FROM userbean WHERE userId=?
      13:06:57,755 DEBUG [UserBean] Table not create as requested: userbean
      13:06:57,785 DEBUG [UserBean#findByPrimaryKey] SQL: SELECT t0_UserBean.userId FROM userbean t0_UserBean WHERE t0_UserBean.userId=?
      13:06:57,788 DEBUG [UserBean] Added findByPrimaryKey query command for local home interface
      13:06:57,791 DEBUG [UserBean#findByUserId] EJB-QL: SELECT OBJECT(a) FROM UserBean AS a WHERE a.userId = ?1
      13:06:58,001 DEBUG [UserBean#findByUserId] SQL: SELECT t0_a.userId FROM userbean t0_a WHERE (t0_a.userId = ?)
      13:06:58,001 DEBUG [CachedConnectionInterceptor] start called in CachedConnectionInterceptor
      13:06:58,002 DEBUG [EjbModule] Started jboss.j2ee:service=EjbModule,module=TelePetEJB.jar
      13:06:58,002 DEBUG [ServiceController] Starting dependent components for: jboss.j2ee:service=EjbModule,module=TelePetEJB.jar dependent components: []
      13:06:58,002 INFO [EJBDeployer] Deployed: file:/usr/local/jboss-4.0.4.GA/server/telepet/tmp/deploy/tmp27980TelePetApp.ear-contents/TelePetEJB.jar
      13:06:58,105 DEBUG [MainDeployer] End deployment start on package: TelePetEJB.jar
      13:06:58,173 DEBUG [ServiceController] starting service jboss.j2ee:service=EARDeployment,url='TelePetApp.ear'
      13:06:58,174 DEBUG [EARDeployment] Starting jboss.j2ee:service=EARDeployment,url='TelePetApp.ear'
      13:06:58,174 DEBUG [EARDeployment] Started jboss.j2ee:service=EARDeployment,url='TelePetApp.ear'
      13:06:58,174 DEBUG [ServiceController] Starting dependent components for: jboss.j2ee:service=EARDeployment,url='TelePetApp.ear' dependent components: []
      13:06:58,174 INFO [EARDeployer] Started J2EE application: file:/usr/local/jboss-4.0.4.GA/server/telepet/deploy/TelePetApp.ear
      13:06:58,175 DEBUG [MainDeployer] End deployment start on package: TelePetApp.ear
      13:06:58,175 DEBUG [MainDeployer] Deployed package: file:/usr/local/jboss-4.0.4.GA/server/telepet/deploy/TelePetApp.ear
      13:06:58,175 DEBUG [URLDeploymentScanner] Watch URL for: file:/usr/local/jboss-4.0.4.GA/server/telepet/deploy/TelePetApp.ear -> file:/usr/local/jboss-4.0.4.GA/server/telepet/deploy/TelePetApp.ear
      13:06:58,176 DEBUG [AbstractDeploymentScanner$ScannerThread] Notified that enabled: true
      13:06:58,177 DEBUG [URLDeploymentScanner] Started jboss.deployment:type=DeploymentScanner,flavor=URL
      13:06:58,178 DEBUG [ServiceController] Starting dependent components for: jboss.deployment:type=DeploymentScanner,flavor=URL dependent components: []
      13:06:58,229 DEBUG [MainDeployer] End deployment start on package: jboss-service.xml
      13:06:58,230 DEBUG [MainDeployer] Deployed package: file:/usr/local/jboss-4.0.4.GA/server/telepet/conf/jboss-service.xml
      13:06:58,232 DEBUG [Tomcat5] Saw org.jboss.system.server.started notification, starting connectors
      13:06:58,326 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
      13:06:58,972 INFO [ChannelSocket] JK: ajp13 listening on localhost/127.0.0.1:8009
      13:06:58,992 INFO [JkMain] Jk running ID=0 time=0/120 config=null
      13:06:59,017 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 36s:492ms