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

    • Icon: Sub-task Sub-task
    • Resolution: Unresolved
    • Icon: Major Major
    • 3.x Future
    • 2.12.2.Final
    • Java EE
    • None

      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;
         }
      

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

                Created:
                Updated: