It's impossible to use static variables on a session bean code. Is this restriction arbitrary or fundamented? And why?
Best regards
It's impossible to use static variables on a session bean code. Is this restriction arbitrary or fundamented? And why?
Best regards
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                
staticmeans unique for a class OR for all it's objects.
Now, javabeans are supposed to have user-specific data, static fields don't make any sense for these.
One user edits a variable, ant it'll be updated for all other users too. (at free of cost :-)).
However if you want static behaviour for these (i.e. using same data for all users), you have application for that purpose.
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                It is fundamental. As per this sun documenation,
Nonfinal static class fields are disallowed in EJBs because such fields make an enterprise bean difficult or impossible to distribute. Static class fields are shared among all instances of a particular class, but only within a single Java Virtual Machine (JVM). *
As stated in the FAQ on EJB restrictions, one of the restrictions for using EJBs is:
Further expanded in the discussion on static fields: