lishunli / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

Support Generation of all the DTO named queries.. #511

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am power user and power recommender of your annotations.

In all the DTO's there are bunch of annotations generated by Netbeans IDE.

I wish lombok provides a way to auto generate all the annotations related to a 
class at compile time..

Also, it should allow custom insertions logic for each of the annotation e.g

@ToString (customHandler="MyHandler.class")

etc..

Template Class I have is 

package com.bt.intalio.db;

import com.bt.intalio.db.consts.IntalioDBConsts;
import lombok.Getter;
import lombok.ToString;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.sql.Timestamp;

@Entity
@Table(name = IntalioDBConsts.BPEL_INSTANCE)
@NamedQueries({
              @NamedQuery(name = BPELInstance.CL_FIND + "All", query = BPELInstance.SELECT_FROM),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "Id", query = BPELInstance.SELECT_WHERE + "id = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "InstantiatingCorrelator",
                  query = BPELInstance.SELECT_WHERE + "instantiatingCorrelator = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "Fault", query = BPELInstance.SELECT_WHERE + "fault = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "JacobState", query = BPELInstance.SELECT_WHERE + "jacobState = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "PreviousState", query = BPELInstance.SELECT_WHERE + "previousState = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "State", query = BPELInstance.SELECT_WHERE + "state = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "LastActiveDt", query = BPELInstance.SELECT_WHERE + "lastActiveDt = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "Sequence", query = BPELInstance.SELECT_WHERE + "sequence = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "FailureCount", query = BPELInstance.SELECT_WHERE + "failureCount = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "FailureDt", query = BPELInstance.SELECT_WHERE + "failureDt = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "InsertTime", query = BPELInstance.SELECT_WHERE + "insertTime = ?1"),
              @NamedQuery(name = BPELInstance.CL_FIND_BY + "Mlock", query = BPELInstance.SELECT_WHERE + "mlock = ?1")
          })
@Getter
@ToString(exclude = "id")
public final class BPELInstance extends AbstBPELPersist
{
    public static final String CL_NAME = "BPELInstance";
    public static final String CL_FIND = CL_NAME + ".find";
    public static final String CL_FIND_BY = CL_FIND + "By";
    public static final String SELECT_FROM = "SELECT b FROM " + CL_NAME + " b";
    public static final String SELECT_WHERE = SELECT_FROM + " WHERE b.";
    public static final String findAll = CL_FIND + "All";

    @Column(name = IntalioDBConsts.INSTANTIATING_CORRELATOR, nullable = true, insertable = false, updatable = false)
    private Long instantiatingCorrelator;

    @Column(name = IntalioDBConsts.FAULT, nullable = true, insertable = false, updatable = false)
    private Long fault;

    @Column(name = IntalioDBConsts.JACOB_STATE, nullable = true, insertable = false, updatable = false)
    private Long jacobState;

    @Column(name = IntalioDBConsts.PREVIOUS_STATE, nullable = true, insertable = false, updatable = false)
    private Short previousState;

    @Column(name = IntalioDBConsts.STATE, nullable = true, insertable = false, updatable = false)
    private Short state;

    @Column(name = IntalioDBConsts.FAILURE_COUNT, nullable = true, insertable = false, updatable = false)
    private Short failureCount;

    @Column(name = IntalioDBConsts.FAILURE_DT, nullable = true, insertable = false, updatable = false)
    private Timestamp failureDt;
    @Column(name = IntalioDBConsts.INSERT_TIME, nullable = true, insertable = false, updatable = false)
    private Timestamp insertTime;

    @Column(name = IntalioDBConsts.MLOCK, nullable = false, insertable = false, updatable = false)
    private int mlock;

    @Column(name = IntalioDBConsts.LAST_ACTIVE_DT, nullable = true, insertable = false, updatable = false)
    private Timestamp lastActiveDt;

    @Column(name = IntalioDBConsts.SEQUENCE, nullable = true, insertable = false, updatable = false)
    private Long sequence;

    @ManyToOne(cascade = CascadeType.ALL, targetEntity = BPELProcess.class, fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = IntalioDBConsts.PROCESS_ID, referencedColumnName = IntalioDBConsts.ID, nullable = false)
    private BPELProcess bpelProcess;
}

Original issue reported on code.google.com by nagendra...@gmail.com on 23 Apr 2013 at 6:51

GoogleCodeExporter commented 9 years ago
More Attachments

Original comment by nagendra...@gmail.com on 23 Apr 2013 at 6:55

Attachments:

GoogleCodeExporter commented 9 years ago
We don't do _anything_ with DTOs, so there are 2 major problems here:

* We don't even know what to look for. For example, which of the annotations in 
your example are generated by netbeans, and how does netbeans know what to 
generate? If it is the @Column annotations that we should generate, how do we 
know whether they are nullable, etcetera? If it's the @NamedQueries blob, how 
would we know what to generate for all those string constants?

* We don't care. As in, we would never use this, and that's problematic because 
we do this in our free time. It would be a lot more logical if someone who 
would actively use this in their daily programming life would write and 
maintain this handler.

Original comment by reini...@gmail.com on 25 Apr 2013 at 9:01

GoogleCodeExporter commented 9 years ago
> I wish lombok provides a way to auto generate all the annotations related to 
a class at compile time..

I see a different problem with this:

Either these annotation contain some additional information and then it can't 
be generated automatically.

Or they do not and then they're redundant and the framework requiring them is a 
crap.

Am I missing something?

Original comment by Maaarti...@gmail.com on 9 Oct 2013 at 8:58