EJB depth analysis: WebLogic entity bean lags in 'lazy loading' .... (from dev2dev)

zhaozj2021-02-16  140

Author: xlg1979

The load part of the WebLogic entity bean is studied, and the timing of the entity bean is synchronized from the database. Personally think that these things can use good CMP entity beans to master the essence of EJB, entity beans will use It is difficult to say, in fact, I have found the shortcomings of the WebLogic CMP entity bean implementation :) Maybe bug.1. Simple entity bean, without association .1) Dominant to execute a. From execution EJBHOME .findbyprimarykey, this method returns a EntityBean instance that elects a 'Ready' state from an instance pool, b. By default, according to the fields in the database in the database, how much dependence is loaded The field group set in the configuration file (default load entity bean all fields) c. Then execute the EJBLOAD method (this method is nothing, no big use for entity beans) d. End Finder method If you follow the entity The GET / SET method for the bean local interface is to change the field value of the entity bean. The entity bean will not have too much change unless it is selected, which is executed every Get / SET method. EJBSTORE method synchronization database .2) But if you add Finders Load bean = false in the configuration file, you can control data in the table when performing EjBhome.FindByPrimaryKey, with the following execution process: a. Top the database, Whether the main health exists, if there is no ObjectNotFoundException, pay attention, not to extract the EntityBean instance B.Finder method from the instance pool, actually no synchronization database data. If you follow the entity bean local interface GET / SET method: C1. First select an EntityBean instance C2 in the 'Ready' state in the instance pool. Execute the EJBLOAD method (execution order and 1) of the EJBLOAD, he is before loading data) C3. Loading the EntityBean data, synchronized the database. But there is a subtle difference between the GET, SET method. 2. If the entity bean is related to the FindByPrimaryKey (..) method of the implementing entity bean, note: This method is only loaded into this The database data of the entity bean is not loaded for some CMR fields, that is, if not loading the data of other entity beans associated with this entity bean, if Get / The SET method does not load the associated data. But if you do a getCMRField method, you don't see it immediately to load the associated data, look at the following method Collection c = entityBean.getCMRField (); then return an empty C, I haven't loaded entity bean. But I want to see how many entity beans returned, do the following operation int count = C.Size (); this method is going to do for a long time, because WebLogic is designed like this, when you The true call C method will be loaded when the method is called, this is 'lazy loading'! 3. When this is relatively simple, WebLogic is ended by the transaction processing in Entity Bean. Time to trigger, but can also change. Look at this option, it's not very clear. Delicate, I haven't found a lot of details, these I can't find it online, I am trying to compile WebLogic. Conclusion. In addition, you can also look at those files generated by WebLogic.ejbc, and the name is quicker as Yyso_GQF3go__weblogic_cmp_rdbms, and how many answers can be found.

转载请注明原文地址:https://www.9cbs.com/read-8415.html

New Post(0)