This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 172629

Summary: "Enitty Classes from Database" should initialize collections when needed
Product: javaee Reporter: err <err>
Component: PersistenceAssignee: Sergey Petrov <sj-nb>
Status: RESOLVED WONTFIX    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description err 2009-09-20 22:12:23 UTC
Running this code
        Table1 t1 = new Table1();
        Table2 t2a = new Table2();
        Table2 t2b = new Table2();

        t1.getTable2Collection().add(t2a);
        t1.getTable2Collection().add(t2b);
get NPE on the add method. Assuming you want quick prototyping, generating something like the following seems approprate
    public Collection<Table2> getTable2Collection() {
        if(table2Collection == null)
            table2Collection = new ArrayList<Table2>();
        return table2Collection;
    }
Comment 1 Sergey Petrov 2009-10-26 16:33:42 UTC
it's unclear for me if it's really good to implement or not, but looks like enhancement for me. less check always good
me if it works as users can create code where this verification will be unnecessary but verification will still consume
some processor time and make code more complex.
for quick prototyping it's should be easy to use setTable2Collection instead of getTable2Collection, may be frst check
if get.. retun null. 
Comment 2 Martin Balin 2016-07-07 08:55:06 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss