Bug 203659

Summary: Generate new lines between fields of a JPA entity
Product: javaee Reporter: Petr Jiricka <pjiricka>
Component: PersistenceAssignee: Sergey Petrov <sj-nb>
Status: REOPENED --- QA Contact: issues <issues.netbeans.org>
Priority: P3 CC: arungupta
Version: 7.1Keywords: USABILITY
Target Milestone: TBD   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Issue Type: ENHANCEMENT Exception Report:

Description Petr Jiricka 2011-10-13 14:25:40 UTC
Here is a snipped from an entity class generated using Entities from Database:

    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "CUSTOMER_ID")
    private Integer customerId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "ZIP")
    private String zip;
    @Size(max = 30)
    @Column(name = "NAME")
    private String name;

This code is hard to read - it would be useful if there was an empty line after each field.
Comment 1 Sergey Petrov 2011-10-13 14:45:49 UTC
It's the way our java api generate class from class tree, if I extract superclass with refactor action, there will be no newlines also, but may be I can add empty lines to class model, I'm not sure, requires more evaluation.
Also generated code in forms have fields on each line, it may be too custom for persistence фкуф to have newline between ашудвы also it may be user preference dependent.
Comment 2 Sergey Petrov 2011-10-13 14:50:34 UTC
after brief investigation I found option 
Editor|Formatting
Language: Java
Category: blank lines
option "after field".
it's 0 by default and if changes to 1 entity class will be generated with newlines after each field. 
if there is no request to override this option for persistence of have separate configuration for entities from db looks like the issue isn't valid. feel free to reopen if persistence need something special.
Comment 3 Sergey Petrov 2011-11-29 14:27:14 UTC
*** Bug 191331 has been marked as a duplicate of this bug. ***
Comment 4 arungupta 2012-02-13 13:11:30 UTC
Even though there is an option to override the field manually but the generated code still looks ugly. I'd recommend finding a way to exposing it programmatically and then overriding in the JPA entity generators.

I always have to add a blank line to show the fields clearly.
Comment 5 Sergey Petrov 2012-02-13 13:33:51 UTC
It's unclear why it should be specific to persistence?
May it be better to request other defaults in general class format configuration?
Also why you can't change these defaults?
Comment 6 arungupta 2012-02-13 13:36:18 UTC
Actually, thinking more about the general format should be changed itself.

Will that be a separate bug ?

I can change my preferences but when I'm teaching Java EE 6 labs using NetBeans, its cumbersome if everybody has to change it. And its anyway more readable :-)
Comment 7 Sergey Petrov 2012-02-13 13:40:52 UTC
Any generator works this way, as mentioned above "extract super class" and firms but even more simple like "new|Java beans|Java bean" will create java bean with members on each line (yet it may be less fields then usually in an entity).
It it's specific to support customization in place(i.e. wizard step) it's more like enhancment for persistence area, but you can try also to file more general issue.
Comment 8 Sergey Petrov 2012-03-19 09:15:29 UTC
any progress on general issue?
as I said having general functionality to configure newlines, it's more like enhancement to extend some specific wizard to support customization in place so if you don't mind -> enhancement. it may have sense to review also in genral for ide if it's good to have this for most generator's wizards.
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo