1 Reply Latest reply on May 21, 2004 3:25 AM by ironbird

    My records from database is getting deleted during retrieve

    Arup Choudhury Newbie

      Hello:

      I am jboss3.2.3 with mysql. I am observing a behaviour which does not make sense.

      I am creating an entity object and then trying to retrieve it through session facade. Sometime findByPrimaryKey() is iving me "Object Not Found" exception and also deleting the row from the database.

      Can any body help. It is very urgeny.

      Thanks

      Arup

      My ejb-jar.xml looks something like this and I am trying to retrieve the Operator object.

      !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>
      <enterprise-beans>

      <ejb-name>UserManagementFacade</ejb-name>
      com.equatorone.max.apps.usermgmt.server.session.UserManagementFacadeHome
      com.equatorone.max.apps.usermgmt.server.session.UserManagementFacade
      <ejb-class>com.equatorone.max.apps.usermgmt.server.session.UserManagementFacadeBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-local-ref>
      No Description
      <ejb-ref-name>OperatorHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>OperatorLocalHome</local-home>
      OperatorLocal
      <ejb-link>Operator</ejb-link>
      </ejb-local-ref>
      <ejb-local-ref>
      No Description
      <ejb-ref-name>PrivilegeHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>PrivilegeLocalHome</local-home>
      PrivilegeLocal
      <ejb-link>Privilege</ejb-link>
      </ejb-local-ref>


      <ejb-name>GroupManagementFacade</ejb-name>
      com.equatorone.max.apps.usermgmt.server.session.GroupManagementFacadeHome
      com.equatorone.max.apps.usermgmt.server.session.GroupManagementFacade
      <ejb-class>com.equatorone.max.apps.usermgmt.server.session.GroupManagementFacadeBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-local-ref>
      No Description
      <ejb-ref-name>OperatorHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>OperatorLocalHome</local-home>
      OperatorLocal
      <ejb-link>Operator</ejb-link>
      </ejb-local-ref>
      <ejb-local-ref>
      No Description
      <ejb-ref-name>GroupInfoHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>GroupInfoLocalHome</local-home>
      GroupInfoLocal
      <ejb-link>GroupInfo</ejb-link>
      </ejb-local-ref>
      <ejb-local-ref>
      No Description
      <ejb-ref-name>UserGroupHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>UserGroupLocalHome</local-home>
      UserGroupLocal
      <ejb-link>UserGroup</ejb-link>
      </ejb-local-ref>


      <display-name>Operator Entity Bean</display-name>
      <ejb-name>Operator</ejb-name>
      <table-name>operator</table-name>
      <local-home>com.equatorone.max.apps.usermgmt.server.entity.OperatorLocalHome</local-home>
      com.equatorone.max.apps.usermgmt.server.entity.OperatorLocal
      <ejb-class>com.equatorone.max.apps.usermgmt.server.entity.OperatorBean</ejb-class>

      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>

      <abstract-schema-name>operator</abstract-schema-name>
      <primkey-field>id</primkey-field>
      <prim-key-class>java.lang.String</prim-key-class>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>type</field-name></cmp-field>
      <cmp-field><field-name>password</field-name></cmp-field>
      <cmp-field><field-name>rootpath</field-name></cmp-field>
      <cmp-field><field-name>emailaddress</field-name></cmp-field>
      <cmp-field><field-name>mobile</field-name></cmp-field>
      <cmp-field><field-name>pager</field-name></cmp-field>
      <cmp-field><field-name>resourcehidelimit</field-name></cmp-field>
      <cmp-field><field-name>parentname</field-name></cmp-field>


      <display-name>Privilege Entity Bean</display-name>
      <ejb-name>Privilege</ejb-name>
      <table-name>privilege</table-name>
      <local-home>com.equatorone.max.apps.usermgmt.server.entity.PrivilegeLocalHome</local-home>
      com.equatorone.max.apps.usermgmt.server.entity.PrivilegeLocal
      <ejb-class>com.equatorone.max.apps.usermgmt.server.entity.PrivilegeBean</ejb-class>
      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>

      <abstract-schema-name>privilege</abstract-schema-name>

      <primkey-field>id</primkey-field>
      <prim-key-class>java.lang.String</prim-key-class>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>alarm</field-name></cmp-field>
      <cmp-field><field-name>changepassword</field-name></cmp-field>
      <cmp-field><field-name>threshold</field-name></cmp-field>
      <cmp-field><field-name>reports</field-name></cmp-field>
      <cmp-field><field-name>resource</field-name></cmp-field>
      <cmp-field><field-name>delalarm</field-name></cmp-field>
      <cmp-field><field-name>notifier</field-name></cmp-field>
      <cmp-field><field-name>users</field-name></cmp-field>
      <cmp-field><field-name>systemfunc</field-name></cmp-field>
      <cmp-field><field-name>replication</field-name></cmp-field>


      <display-name>UserGroup Entity Bean</display-name>
      <ejb-name>UserGroup</ejb-name>
      <table-name>usergroup</table-name>
      <local-home>com.equatorone.max.apps.usermgmt.server.entity.UserGroupLocalHome</local-home>
      com.equatorone.max.apps.usermgmt.server.entity.UserGroupLocal
      <ejb-class>com.equatorone.max.apps.usermgmt.server.entity.UserGroupBean</ejb-class>
      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>

      <abstract-schema-name>usergroup</abstract-schema-name>
      <primkey-field>id</primkey-field>
      <prim-key-class>java.lang.String</prim-key-class>
      <cmp-field><field-name>id</field-name></cmp-field>


      <display-name>GroupInfo Entity Bean</display-name>
      <ejb-name>GroupInfo</ejb-name>
      <table-name>groupinfo</table-name>
      <local-home>com.equatorone.max.apps.usermgmt.server.entity.GroupInfoLocalHome</local-home>
      com.equatorone.max.apps.usermgmt.server.entity.GroupInfoLocal
      <ejb-class>com.equatorone.max.apps.usermgmt.server.entity.GroupInfoBean</ejb-class>
      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>

      <abstract-schema-name>groupinfo</abstract-schema-name>

      <primkey-field>id</primkey-field>
      <prim-key-class>java.lang.String</prim-key-class>
      <cmp-field><field-name>groupname</field-name></cmp-field>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>description</field-name></cmp-field>

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>Operator-Parent</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Operator-has-Parents
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Operator</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>operatorscreated</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Operator-belongs-to-Operator
      </ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>Operator</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>Operator-Privilege</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Operator-has-Privilege
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Operator</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>privilege</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Privilege-belongs-to-Operator
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Privilege</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>Group-Creator</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Group-has-Creator
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Operator</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>groupscreated</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Operator-Creates-Group
      </ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>GroupInfo</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>Operator-UserGroup</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Operator-is-associated-to-UserGroup
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Operator</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>groups</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      UserGroups-to-Operator
      </ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>UserGroup</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>Group-UserGroup</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Group-is-associated-to-UserGroup
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>GroupInfo</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>members</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      UserGroups-to-Group
      </ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>UserGroup</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>


      <assembly-descriptor>
      <container-transaction>

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

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

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

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

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

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

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

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

        • 1. Re: My records from database is getting deleted during retri
          ironbird Newbie

           


          I am jboss3.2.3 with mysql. I am observing a behaviour which does not make sense.

          I am creating an entity object and then trying to retrieve it through session facade. Sometime findByPrimaryKey() is iving me "Object Not Found" exception and also deleting the row from the database.


          Quite curious and unbelievable ! I don't think that the container itself delete the row from the database. More logical, you get a Object Not Found exception because the row was deleted before.
          Look at your code, and post it if needed.