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 - "Enitty Classes from Database" should initialize collections when needed
Summary: "Enitty Classes from Database" should initialize collections when needed
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-20 22:12 UTC by err
Modified: 2016-07-07 08:55 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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