New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @java.beans.ConstructorProperties when fetching into immutable POJOs #1837

Closed
agentgt opened this Issue Sep 21, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@agentgt

agentgt commented Sep 21, 2012

Lukas

In org.jooq.tools.reflect.Reflect.as(Class<P>) and org.jooq.impl.AbstractRecord.intoImmutablePOJO(Class<? extends T>)

it would be nice if you took advantage of @ConstructorProperties annotation:

http://docs.oracle.com/javase/6/docs/api/java/beans/ConstructorProperties.html

Its built into the JDK so no dependencies.

@lukaseder

This comment has been minimized.

Show comment
Hide comment
@lukaseder

lukaseder Sep 21, 2012

Member

That is a very nice idea. I can see how it will work in org.jooq.impl.AbstractRecord.intoImmutablePOJO(Class<? extends T>). This would be the rule-set:

  1. If no @ConstructorProperties is present, the behaviour is like today (matching fields onto arguments by index)
  2. If @ConstructorProperties is present, match fields onto arguments via the existing rules applied to getters as indicated in the annotation. This will work for both JPA-annotated POJOs as well as plain ones.

Could you please elaborate how this should be used in org.jooq.tools.reflect.Reflect.as(Class<P>) ? There isn't really any constructor call in there...?

Member

lukaseder commented Sep 21, 2012

That is a very nice idea. I can see how it will work in org.jooq.impl.AbstractRecord.intoImmutablePOJO(Class<? extends T>). This would be the rule-set:

  1. If no @ConstructorProperties is present, the behaviour is like today (matching fields onto arguments by index)
  2. If @ConstructorProperties is present, match fields onto arguments via the existing rules applied to getters as indicated in the annotation. This will work for both JPA-annotated POJOs as well as plain ones.

Could you please elaborate how this should be used in org.jooq.tools.reflect.Reflect.as(Class<P>) ? There isn't really any constructor call in there...?

@agentgt

This comment has been minimized.

Show comment
Hide comment
@agentgt

agentgt Sep 21, 2012

Whoops I didn't realize as(Class<P>) is proxying interfaces.

Another enhancement I would like is the ability to create the default Record.class (ie I would like to wrap RecordImpl.class).

Example here in the CursorImp.class where RecordImpl.class is hard codeded.

@SuppressWarnings("unchecked")
CursorImpl(ExecuteContext ctx, ExecuteListener listener, FieldProvider fields, boolean keepStatementOpen) {
    this(ctx, listener, fields, (Class<? extends R>) RecordImpl.class, keepStatementOpen);
}

If I can decorate RecordImpl.class or create my own then I can control the mapping to a POJO org.jooq.Record.into(E). Write now I don't see how that's possible. ie I think there should a default RecordFactory should be pluggable.

agentgt commented Sep 21, 2012

Whoops I didn't realize as(Class<P>) is proxying interfaces.

Another enhancement I would like is the ability to create the default Record.class (ie I would like to wrap RecordImpl.class).

Example here in the CursorImp.class where RecordImpl.class is hard codeded.

@SuppressWarnings("unchecked")
CursorImpl(ExecuteContext ctx, ExecuteListener listener, FieldProvider fields, boolean keepStatementOpen) {
    this(ctx, listener, fields, (Class<? extends R>) RecordImpl.class, keepStatementOpen);
}

If I can decorate RecordImpl.class or create my own then I can control the mapping to a POJO org.jooq.Record.into(E). Write now I don't see how that's possible. ie I think there should a default RecordFactory should be pluggable.

@lukaseder

This comment has been minimized.

Show comment
Hide comment
@lukaseder

lukaseder Sep 21, 2012

Member
  • as(Class<P>): OK, I'll rename the ticket and implement the immutable POJO part
  • RecordImpl.class: Could you please open a separate ticket for this?
Member

lukaseder commented Sep 21, 2012

  • as(Class<P>): OK, I'll rename the ticket and implement the immutable POJO part
  • RecordImpl.class: Could you please open a separate ticket for this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment