Thursday, September 25, 2008

EJB -> Errors

1).While working with entity bean I got entity does not found the object 'CABIN' (table name)
this is my mistake , i did not create the table in the proper database .

2)Now I got the following error.
--------------------------------

javax.ejb.CreateException: Error checking if entity exists:java.sql.SQLException: Line 1: Incorrect syntax near 'WHERE'.
at org.jboss.ejb.plugins.cmp.jdbc.JDBCInsertPKCreateCommand.beforeInsert(JDBCInsertPKCreateCommand.java:105)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:150)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:587)

Sol: This error gone when i change the cabinPK class variable to primary key filed.

previously it has id as field , now i changed to the primary key filed name as metioned in the bean class. And I changed the method names to plane like previously i has getRsCardNo

i changed that to getCardno.

Solution:

CMP:(container managed persistance).

Actually container will find our entity bean by using primay key , In ejb-jar.xml I metioned the primary class name as NamedQueryAPK class . But there is no column with that class type.

So I changed the primay key class as java.lang.String and primary key field as BName( stiring and one of the column of the table) . Now the container is able to find the entity and created a row in the table.

Note: One thing that i observed is , when i call a entity bean directly from the client that time I gabe the primary key class as CabinPK but container does not through any error. But this time( calling entity bean from session bean) it thrown create exception.

No comments: