aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes entity bean finder exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "entity bean finder exception" Watch "entity bean finder exception" New topic
Author

entity bean finder exception

Kawa Sakura
Greenhorn

Joined: Nov 27, 2005
Posts: 4
Hi all,
When I iteratively call entity bean's findByPrimaryKey method, it works well for the first time, it means that it find out the corresponding record in the database, but after this first time, even though I put the same primary key argument in the call of this finder method, it can not find the result.
Anyone who can help me? Thanks for your helps.
Best regards.
PS: Sorry for my bad English
Kawa Sakura
Greenhorn

Joined: Nov 27, 2005
Posts: 4
This is the code for entity bean
-------------------------
package com.abc.un.beans;

import java.rmi.RemoteException;


import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;

/**
* @ejb.bean
* name="DocspaceEntity"
* primkey-field = "docspaceID"
* type="CMP"
* cmp-version = "2.x"
* jndi-name="DocspaceEntityCMP"
*
*
* @ejb.transaction
* type="Supports"
*
* @ejb.finder
* method-intf = "LocalHome"
* query = "SELECT OBJECT(o) FROM DocspaceEntity o"
* signature="java.util.Collection findAll()"
*
*
* @ejb.persistence
* table-name="T_Docspace"
*
* @ejb.value-object
* match = "*"
* name = "DocspaceEntityData"
*
* @ejb.permission
* unchecked = "true"
*
* @ejb.security-role-ref
* role-name = "dms"
* role-link = "dms"
* @ejb.security-identity
* use-caller-identity = "true"
*/

abstract public class DocspaceEntityBean implements EntityBean {
EntityContext entityContext;

/**
* @ejb.create-method
*
* @param pK_DocspaceID
* @param displayName
* @param descriptiveText
* @param fK_CreatedByID
* @param fK_DeletedByUserID
* @param lastModificationDateTime
* @param displayOrder
* @return
* @throws CreateException
*/
public String ejbCreate(java.lang.String docspaceID, java.lang.String displayName, java.lang.String descriptiveText, java.lang.String fK_CreatedByID, java.lang.String fK_DeletedByUserID, java.util.Date lastModificationDateTime, java.lang.Long displayOrder) throws CreateException {

setDocspaceID(docspaceID);

setDisplayName(displayName);

setDescriptiveText(descriptiveText);

setFK_CreatedByID(fK_CreatedByID);

setFK_DeletedByUserID(fK_DeletedByUserID);

setLastModificationDateTime(lastModificationDateTime);

setDisplayOrder(displayOrder);

return null;
}
public void ejbPostCreate(java.lang.String docspaceID, java.lang.String displayName, java.lang.String descriptiveText, java.lang.String fK_CreatedByID, java.lang.String fK_DeletedByUserID, java.util.Date lastModificationDateTime, java.lang.Long displayOrder) throws CreateException {
/**@todo Complete this method*/
}

/**
* @ejb.pk-field
* @ejb.interface-method
* @ejb.persistent-field
* @ejb.persistence
* column-name="PK_DocspaceID"
* jdbc-type = "VARCHAR"
* sql-type="CHAR(36)"
*
*/
public abstract void setDocspaceID(java.lang.String docspaceID);

/**
* @ejb.pk-field
* @ejb.interface-method
* @ejb.persistent-field
* @ejb.persistence
* column-name="PK_DocspaceID"
* jdbc-type = "VARCHAR"
* sql-type="CHAR(36)"
*
*/
public abstract java.lang.String getDocspaceID();


/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="DisplayName"
* jdbc-type = "VARCHAR"
* sql-type="VARCHAR(255)"
*/
public abstract void setDisplayName(java.lang.String displayName);

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="DisplayName"
* jdbc-type = "VARCHAR"
* sql-type="VARCHAR(255)"
*
*/
public abstract java.lang.String getDisplayName();


/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="DescriptiveText"
* jdbc-type = "VARCHAR"
* sql-type="VARCHAR(255)"
*/
public abstract void setDescriptiveText(java.lang.String descriptiveText);


/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="DescriptiveText"
* jdbc-type = "VARCHAR"
* sql-type="VARCHAR(255)"
*
*/
public abstract java.lang.String getDescriptiveText();


/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="FK_CreatedByID"
* jdbc-type = "VARCHAR"
* sql-type="CHAR(36)"
*
*/
public abstract void setFK_CreatedByID(java.lang.String fK_CreatedByID);

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="FK_CreatedByID"
* jdbc-type = "VARCHAR"
* sql-type="CHAR(36)"
*/
public abstract java.lang.String getFK_CreatedByID();

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="FK_DeletedByUserID"
* jdbc-type = "VARCHAR"
* sql-type="CHAR(36)"
*
*/
public abstract void setFK_DeletedByUserID(java.lang.String fK_DeletedByUserID);

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="FK_DeletedByUserID"
* jdbc-type = "VARCHAR"
* sql-type="CHAR(36)"
*/
public abstract java.lang.String getFK_DeletedByUserID();

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="LastModificationDateTime"
* sql-type="Date"
*
*/
public abstract void setLastModificationDateTime(java.util.Date lastModificationDateTime);

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="LastModificationDateTime"
* sql-type="Date"
*/
public abstract java.util.Date getLastModificationDateTime();

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="DisplayOrder"
* sql-type="FLOAT(7)"
*/
public abstract void setDisplayOrder(java.lang.Long displayOrder);

/**
* @ejb.persistent-field
* @ejb.interface-method
* @ejb.persistence
* column-name="DisplayOrder"
* sql-type="FLOAT(7)"
*/
public abstract java.lang.Long getDisplayOrder();


/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbActivate()
*/
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbLoad()
*/
public void ejbLoad() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbRemove()
*/
public void ejbRemove()
throws RemoveException, EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbStore()
*/
public void ejbStore() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
*/
public void setEntityContext(EntityContext entityContext)
throws EJBException, RemoteException {
this.entityContext = entityContext;

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#unsetEntityContext()
*/
public void unsetEntityContext() throws EJBException, RemoteException {
this.entityContext = null;

}

}

I called only the findByPrimary method of this entity local home interface. It run well for the first time, the second time, it can not find the record, and the third time it run well again.

[ November 29, 2005: Message edited by: Kawa Sakura ]
[ November 29, 2005: Message edited by: Kawa Sakura ]
Sunil Dixit
Ranch Hand

Joined: Sep 22, 2005
Posts: 46
Hi,
can u show the piece of code if u can
Thanks
Sunil Dixit
Ranch Hand

Joined: Sep 22, 2005
Posts: 46
Hi,
Yaar i mean to say the code which is manipulating CMP not the CMP code
Kawa Sakura
Greenhorn

Joined: Nov 27, 2005
Posts: 4
Originally posted by Sunil Dixit:
Hi,
Yaar i mean to say the code which is manipulating CMP not the CMP code


Could you explain more detailed? I must use this piece of code that was developed by an another one. Anh I would like to show other people that this code is not good. Thank you so much.
Sunil Dixit
Ranch Hand

Joined: Sep 22, 2005
Posts: 46
Choice is urs ......
actually i wanna to see the peice of code which is manipulating ur cmp to reterive the data i.e. code written inside session bean .....
Kawa Sakura
Greenhorn

Joined: Nov 27, 2005
Posts: 4
The piece of code where entity finder method was called.
-----
DocSpaceEntityLocalHome docspaceHome = null;
DocSpaceEntityLocal docspace = null;

try
{
docspaceHome = (DocspaceEntityLocalHome)context.lookup(DocspaceEntityLocalHome.JNDI_NAME);

docspace = (DocspaceEntityLocal) docspaceHome.findByPrimaryKey(GUID);

}catch (Exception e)
{
System.out.println("Error while loading doc space");
e.printStackTrace();
}
----
 
wood burning stoves
 
subject: entity bean finder exception