Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Using constructor injection with JPA entities

JPA 1.0 supports field access, so you do not need set methods if you use
field access, which is normally the better way to go anyway.


cowwoc wrote:
> 
> Hi,
> 
> I am curious whether it conceivably possible for JPA 2.0 to add support
> for constructor injection for such things as read-only entities. I'm not a
> fan of the JavaBean design pattern and I'm wondering whether it would be
> possible to move EclipseLink and JPA closer to the Guice way of doing
> things. For example:
> 
> class Foo
> {
>   public Foo(@Named("username") String username, @Named("password") String
> password)
>   {}
> 
>   // mapping annotations go on getters
>   public String getUsername() {}
>   public String getPassword() {}
> 
>   // no setters
> }
> 
> It would be even better if you could pick up the property names directly
> from the variable name but I believe there are technical problems with
> that approach.
> 
> Thank you,
> Gili
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Using-constructor-injection-with-JPA-entities-tp21335376p21351048.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top