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

Hi Gili,

I took a quick look. 'looks like it would be an interesting contribution if someone wanted to contribute code to support this type of functionality.

-Tom

cowwoc wrote:
Hi,

As a follow-up to my previous post I have run across "O/R Broker" that does
exactly what I am looking for. It allows one to query and persist
non-JavaBeans objects. Please see http://orbroker.sourceforge.net/ and
http://orbroker.sourceforge.net/documentation/user-guide.shtml

This project has been dead for a few years now but I don't see anything
stopping us from applying the same techniques in JPA. If I understand
correctly, all we'd need to do is mark up constructor parameters using
@Column to indicate what database column should go into each parameter. This
seems simple enough. What do you think?

Gili


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




Back to the top