Multiple choice technology programming languages

Which of the following statements are true about a CMP entity bean?

  1. You cannot write JDBC code in the bean class to make a connection and send queries to any database.

  2. You cannot write JDBC code in the bean class to change the values of virtual persistent fields of your bean.

  3. You can write JDBC code and get connected to any database you want.

  4. You can write JDBC code to read the virtual persistent fields, but you cannot change their values.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Container-Managed Persistence (CMP), persistent fields are virtual and accessed via abstract getter and setter methods. The container manages their database synchronization, so you cannot write direct JDBC code to modify these virtual fields. While JDBC can be used for other database connections, direct manipulation of CMP-managed fields is strictly prohibited.