Saturday, November 29, 2003 09:32 AM
I will tell you why you are having this problem but you must know that you have a bigger problem which is your design. You should never use JDBC inside a CMP entity bean. You are defeating the purpose of CMP which is abstract all JDBC code for you. If you want to use JDBC, then you should use BMP instead.
Anyways, the reason for your error is because you are using 2 different database connections to access your database: 1 for your entity bean and another for your JDBC connection. As such, your JDBC connection does not yet see the insert done by ejbCreate() because it has not yet committed the transaction. Besides, why are you going to the database with JDBC when your entity bean already has all the data in memory?
Regardless, you must re-design your bean. Don't do JDBC inside a CMP bean.