Problem with BMP Bean also

I am trying to deploy an entity bean on J2EE 1.3.1 APP SERVER.

The Interfaces & bean class are as mentioned below

I am trying bean managed persistance now

I am getting an error 'SQL code not generated for this bean'.

When verified with verifier getting error 'Transaction attributes are not specified'

for create method but actually transaction attributes for create method are required.

What should be the problem ?

Please note that I got the same problem with CMP Bean that's why I am trying for BMP.

//Home Interface

import javax.ejb.EJBHome;

import java.rmi.RemoteException;

import javax.ejb.CreateException;

import javax.ejb.FinderException;

public interface Order1Home extends EJBHome

{

public Order1 create(Integer custId,String itemcode,int quantity) throws

RemoteException,CreateException;

public Order1 findByPrimaryKey(Integer pk) throws RemoteException,FinderException;

}

// Home Interface ends

// Remote Interface

import javax.ejb.EJBObject;

import java.rmi.RemoteException;

public interface Order1 extends EJBObject

{

public void setQuantity(int quantity) throws RemoteException;

public Integer getCustId() throws RemoteException;

public String getItemCode() throws RemoteException;

public int getQuantity() throws RemoteException;

}

// Remote Interface Ends

// Bean Implementation

import javax.ejb.EntityBean;

import javax.ejb.EntityContext;

import javax.ejb.CreateException;

import javax.ejb.RemoveException;

import javax.ejb.FinderException;

import java.util.*;

import java.sql.*;

public class Order1Bean implements EntityBean

{

transient private EntityContext ctx;

public Integer custId;

public String itemCode;

public int quantity;

public void setEntityContext(EntityContext ctx)

{

this.ctx=ctx;

}

public Integer ejbCreate(Integer custId,String itemCode,int quantity) throws

CreateException

{

this.custId=custId;

this.itemCode=itemCode;

this.quantity=quantity;

try

{

String query="insert into order1 values(?,?,?)";

Connection c=DriverManager.getConnection("jdbc:odbc:ask");

PreparedStatement ps=c.prepareStatement(query);

ps.setInt(1,custId.intValue());

ps.setString(2,itemCode);

ps.setInt(3,quantity);

int count=ps.executeUpdate();

return custId;

}

catch(Exception e)

{

throw new CreateException();

}

}

public void ejbPostCreate(Integer custId,String itemCode,int quantity) throws

CreateException

{

}

public void unsetEntityContext()

{

this.ctx=null;

}

public void ejbActivate()

{

}

public void ejbPassivate()

{

}

public Integer ejbFindByPrimaryKey(Integer i) throws FinderException

{

try

{

String query="select count(*) from order1 where custid=?";

Connection c=DriverManager.getConnection("jdbc:odbc:ask");

PreparedStatement ps=c.prepareStatement(query);

ps.setInt(1,i.intValue());

ResultSet rs=ps.executeQuery();

if(rs.next())

{

int count=rs.getInt(1);

if(count==1)

return i;

else

if(count==0)

throw new FinderException("No Data Found");

else

throw new FinderException("Two Many Rows");

}

else

return null;

}

catch(SQLException e)

{

//throw new CreateException();

return null;

}

}

public void ejbLoad()

{

try

{

Integer i=(Integer) ctx.getPrimaryKey();

this.custId=i;

String query="select itemcode,quantity from order1 where custid=?";

Connection c=DriverManager.getConnection("jdbc:odbc:ask");

PreparedStatement ps=c.prepareStatement(query);

ps.setInt(1,i.intValue());

ResultSet rs=ps.executeQuery();

if(rs.next())

{

this.itemCode=rs.getString(1);

this.quantity=rs.getInt(2);

}

rs.close();

ps.close();

c.close();

}

catch(SQLException e)

{

//throw new CreateException();

}

}

public void ejbStore()

{

try

{

String query="update order1 set itemcode= ? quantity= ? where custid=?";

Connection c=DriverManager.getConnection("jdbc:odbc:ask");

PreparedStatement ps=c.prepareStatement(query);

ps.setInt(3,custId.intValue());

ps.setString(1,this.itemCode);

ps.setInt(2,this.quantity);

ps.executeUpdate();

}

catch(Exception e)

{

//throw new CreateException();

}

}

public void ejbRemove() throws RemoveException

{

try

{

String query="delete from order1 where custId=?";

Connection c=DriverManager.getConnection("jdbc:odbc:ask");

PreparedStatement ps=c.prepareStatement(query);

ps.setInt(1,custId.intValue());

int count=ps.executeUpdate();

}

catch(Exception e)

{

throw new RemoveException();

}

}

public void setQuantity(int quantity)

{

this.quantity=quantity;

}

public Integer getCustId()

{

return this.custId;

}

public String getItemCode()

{

return this.itemCode;

}

public int getQuantity()

{

return this.quantity;

}

}

// Bean Ends

[5711 byte] By [askicomputerssangli] at [2007-9-30 17:34:25]
# 1
Can you post snippet of ejb.xml where the create on the home interface is defined? Do you have all the method-params defined for create?
s-mcgowan at 2007-7-6 13:57:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...