Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1926 Adding more commands to Forge and improve existing ones
  3. FORGE-2150

jpa-new-field should generate constructor with not null attributes

    XMLWordPrintable

Details

    • Sub-task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 2.12.2.Final
    • 3.x Future
    • Java EE
    • None

    Description

      When a field is not nullable (either with @Column(nullable=false) or with a @NotNull constraint) it would be helpful to generate a constructor with all the needed not null values (and a default constructor).

      For example, here, I generate an Address entity with not null street1 and city. It would be good to generate a default constructor + another one with these two needed attributes :

      @Entity
      public class Address implements Serializable
      {
      
         @Column(length = 50, nullable = false)
         @Size(min = 5, max = 50)
         @NotNull
         private String street1;
      
         @Column(length = 50, nullable = false)
         @Size(min = 2, max = 50)
         @NotNull
         private String city;
      
         public Address()
         {
         }
      
         public Address(String street1, String city)
         {
            this.street1 = street1;
            this.city = city;
         }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            agoncal Antonio Goncalves (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: