This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Dependency Injection: Field injection and Setter Injection. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Dependency Injection: Field injection and Setter Injection." Watch "Dependency Injection: Field injection and Setter Injection." New topic
Author

Dependency Injection: Field injection and Setter Injection.

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
I am new to the EJB3. Can anybody tell me what is the difference between field Injection and Setter Injection. I got the Field Injectionn but not the Setter Injection. What is the use of the settert Injection and why we need that?
Faraz Ali
Ranch Hand

Joined: May 15, 2008
Posts: 108
Hi,

There is field-based persistence and property-based persistence. In feild-based persistence, annotations are applied directly on instance variable, while in property-based persistence, annotations are applied on getter methods.

I think its all upon your personal taste. Field-based persistence is easier to use but property-based persistence allows data hiding. So its upto you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dependency Injection: Field injection and Setter Injection.
 
Similar Threads
What is the benefit of using Interface Injection?
DI - Constructor injection / Setter Injection ?
Injection at Class Level
how can i Pass an object from an Action to jsp page in struts?
about null value in struts 2