entity - JSF advantage of ManagedEntity vs UnManagedEntity -


i have started studying jsf , have stumbled accross following 2 ways include entities controller managed bean. 1 direct injection entity managedbean, other entity non-managed bean instance variable initialized @ @postconstruct.

what advantages/disadvantages of 1 way or another? second showed "right way" seems it's more complicated maintain.

non-managed entity

@entity public class book {  //...attributes }  @managedbean public class bookcontroller {     private book book;     @postconstruct    public void init() {      book = new book();     }   } 

managed entity

@entity @managedbean public class book implements serializable {       //...attributes }  @managedbean public class bookcontroller {       @managedproperty(name="#{customer}")      private book book;  } 

entities got own lifecycle , managed jpa. it's not recommended (the cdi specification forbids it) declare entities managed beans. better keep reference entity in controller - non-managed entity in case.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -