Hello Jeremy,
 thanx a lot for your reply... attached is the code of the EJB (and
the generated deployment descriptor, i am using XDoclet to generate
EJB)..

the transaction is 'Required'....  

do you know what's the solution? if i don't define any transaction
openejb will complain that no transaction are associated with EJB

regards
  marco

On 8/4/05, Whitlock, Jeremy    x66075 <[EMAIL PROTECTED]> wrote:
> Marco,
>        Without seeing the EJB, I do know that CMP EJBs usually have a
> transaction associated with them.  If this is the case, the database records
> referenced in the EJB are locked and probably can't be deleted from the DB
> until the transaction finishes.  I ran into problems with this a few days
> ago but again, this is only speculation since I don't see the EJB code.
> Take care, Jeremy
> 
> -----Original Message-----
> From: Marco Mistroni [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 04, 2005 3:27 PM
> To: [email protected]
> Subject: [openejb-user] Problems with OpenEJB and DBUnit
> 
> 
> hello all,
>  i am running a set of java test involving some Entity CMP beans.
> I am currently running test using openEJB, and my tests populates a
> database using Dbunit.
> 
> The problem that i have is that the rows created by using an openEJB
> entity bean don't get deleted using dbUnit.
> 
> Could anyone explain me why? the two calls to db.insert and db.delete
> done using dbunit  are done correctly,but the two rows inserted via
> the EJB.create method simply don't get deleted..
> 
> anyone could help? #
> I attach both test cases..
> 
> thanx and regards
>  marco
> 
> _
> This message and any attachments are intended only for the use of the 
> addressee and
> may contain information that is privileged and confidential. If the reader of 
> the
> message is not the intended recipient or an authorized representative of the
> intended recipient, you are hereby notified that any dissemination of this
> communication is strictly prohibited. If you have received this communication 
> in
> error, please notify us immediately by e-mail and delete the message and any
> attachments from your system.
> 
>
package com.myapp.ejb;

import javax.ejb.*;
import java.util.Date;


/**
 * Entity Bean for Expenses
 *
 *
 * @author Marco Mistroni
 *
 * @ejb.bean
 *      name="Entry"
 *      jndi-name="budget/EntryLocalHome"
 *      type="CMP"
 *      cmp-version="1.1"
 *      primkey-field="id"
 *      view-type="remote" 
 *
 * @ejb.persistence table-name="entries"
 *
 * @ejb.finder
 *      signature="java.util.Collection findEntryByDateTypeUserDate(
 *                      int type, java.util.Date start, java.util.Date end, 
String user)"
 *
 * @ejb.finder
 *      signature="java.util.Collection findByTypeUser(int type, String user)"
 *
 * @ejb.finder
 *      signature="java.util.Collection findByDateUser(
 *                                      java.util.Date start, java.util.Date 
end, String user)"
 *
 * @ejb.transaction type="Required"
 *
 * @openejb
 *
 */
public abstract class EntryBean implements EntityBean 
{
        private EntityContext ec;
        public Integer id;


        /** @ejb.create-method */
        public String ejbCreate(Integer id, String description,
                                double amount, int type, Date date) throws 
CreateException {
                this.setId(id);
                this.setDescription(description);
                this.setAmount(amount);
                this.setType(type);
                this.setDate(date);
                return null;
        }




        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract Integer getId();
        public abstract void setId(Integer id);

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract String getDescription();

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract void setDescription(String desc);



        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract double getAmount();

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract void setAmount(double amount);

        

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract int getType();

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract void setType(int type);

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract java.util.Date getDate();

        /** 
         * @ejb.interface-method
         * @ejb.persistence
         */
        public abstract void setDate(java.util.Date date);
        
        
        public void setEntityContext(EntityContext context) {
                ec = context;
        }     

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

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd";>

<ejb-jar >

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

   <enterprise-beans>

      <!-- Session Beans -->
      <session >
         <description><![CDATA[Facade EJB for ExpenseTypes]]></description>

         <ejb-name>BudgetFacade</ejb-name>

         <home>com.myapp.ejb.BudgetFacadeHome</home>
         <remote>com.myapp.ejb.BudgetFacade</remote>
         <ejb-class>com.myapp.ejb.BudgetFacadeSession</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>

         <ejb-ref >
            <ejb-ref-name>ejb/Entry</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <home>com.myapp.ejb.EntryHome</home>
            <remote>com.myapp.ejb.Entry</remote>
            <ejb-link>Entry</ejb-link>
         </ejb-ref>

      </session>

      <session >
         <description><![CDATA[Facade SessionBean for administrative purposes]]></description>

         <ejb-name>AdminFacade</ejb-name>

         <home>com.myapp.ejb.AdminFacadeHome</home>
         <remote>com.myapp.ejb.AdminFacade</remote>
         <ejb-class>com.myapp.ejb.AdminFacadeSession</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>

      </session>

     <!--
       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 <session></session> markup for those beans.
     -->

      <!-- Entity Beans -->
      <entity >
         <description><![CDATA[Entity Bean for Expenses]]></description>

         <ejb-name>Entry</ejb-name>

         <home>com.myapp.ejb.EntryHome</home>
         <remote>com.myapp.ejb.Entry</remote>
         <ejb-class>com.myapp.ejb.EntryCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>java.lang.Integer</prim-key-class>
         <reentrant>False</reentrant>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>id</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>description</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>amount</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>type</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>date</field-name>
         </cmp-field>
         <primkey-field>id</primkey-field>

      </entity>

      <entity >
         <description><![CDATA[User Bean for Expenses]]></description>

         <ejb-name>User</ejb-name>

         <home>com.myapp.ejb.UserHome</home>
         <remote>com.myapp.ejb.User</remote>
         <ejb-class>com.myapp.ejb.UserCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>java.lang.Integer</prim-key-class>
         <reentrant>False</reentrant>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>userId</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>username</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>password</field-name>
         </cmp-field>
         <primkey-field>userId</primkey-field>

      </entity>

     <!--
       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 <entity></entity> markup for those beans.
     -->

   </enterprise-beans>

   <!-- 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 >
      <method >
         <ejb-name>Entry</ejb-name>
          <method-name>*</method-name>
       </method>
       <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.
     -->
   </assembly-descriptor>

</ejb-jar>

Reply via email to