Geertjan's Blog

  • April 29, 2006

The Best Feature Of The Upcoming NetBeans IDE 5.5 (Part 1)

Geertjan Wielenga
Product Manager
NetBeans IDE 5.5 will totally redefine the word "productivity". I mean, forget wimpy little bits of code, pretty little samples, and obsequious hints and suggestions. Think big. How big? Well, how big can you think? That's how big, plus a little bit of extra bigness added on top.

Without any coding whatsoever, you can pull all the data in your database into a Java EE 5 (i.e., standards-based) application. And what kind of application? A little simple one that just shows you what's in your database? Forget about it. Each table in your database, within 5 seconds and about as many clicks of the mouse, will explode onto the web with exactly this result:

Note: I didn't type anything anywhere. Read that last sentence again. Not only did I not code, I didn't even type.

The steps I took were as follows:

  1. Create a web application and check the checkbox that specifies that you want to use JSF. As a result, all the JSF configuration files and libraries are added to your application

  2. Then, choose this menu item and work through a wizard that lets you select the database and each of the tables that you want to work with:

    This is the result when I finish the wizard (i.e., notice the new package org.my.pkg, which contains a Java EE 5 entity class for each table in my database; also notice the Java EE 5 Java Persistence unit in the Configuration Files node, for accessing the database):

  3. Next, use this menu item to select the entity classes that you want to have rendered via the JSF framework:

    This is the result when I finish the wizard (i.e., notice the JSP pages created for each entity class):

  4. Now all you need to do is deploy your application. Then you get a welcome page with a link to a separate page for each entity class (each of which represents a table in the database), as shown in the first screenshot in this blog entry:

    Notice again—no typing whatsoever, just clicking my mouse here and there. And the value of the result? Well, I can inspect the sources and learn from them. As a learning tool for Java EE 5 technologies, this addition takes NetBeans IDE 5.5 to a completely new level. On top of that, my application is good to go, because the IDE has done all the work for me, pulling all my data out of my database, making it presentable, specification-compliant, and easily maintainable. What more can you ask of an IDE?

Join the discussion

Comments ( 68 )
  • Alex Lam Saturday, April 29, 2006

    I'm sure you need to type out the packages' and components' names - but I'll spare you on that one :-P

  • Geertjan Sunday, April 30, 2006
    :-) Defaults for everything, my friend, defaults for everything. (Okay, maybe not the package names, but even there you could, if you so desired, use your mouse to cut and paste from somewhere.)
  • Ansgar Sunday, April 30, 2006
    > What more can you ask of an IDE?
    a decent Reporting-tool like Birt or Crystal
  • Geertjan Sunday, April 30, 2006
    Hi Ansgar, I've heard a lot about this coming up in an upcming release, or at least, a lot of the internal mailing lists have contained a lot of chatter about the necessity of having a reporting tool; so don't be surprised if you see something interesting in this area after the 5.5 release (which is focused specifically on Java EE 5).
  • Tor Norbye Monday, May 1, 2006
    What more can you ask of an IDE?

    Well, the data is now easily maintainable, but there is a big problem with Wizards: They make creating code easy, but not necessarily maintaining it. What if you suddenly decide you want to change something? You need to run the whole wizard again - hopefully you haven't modified your code such that you can delete it. I just ran into this problem this morning. I love the New Action wizard in NetBeans which lets me position my action in a particular location in a menu. It automatically finds all the surrounding filesystem names and adds positional attributes. But I had an existing action - I just wanted to change its location - so I can't run the wizard, I really want to edit the "properties" of the action.

    Which gets me back to my point: Wizards are great, but one thing we could do ("what more could you ask of an IDE?") is to push some of this in the direction of components, where you can edit settings from the wizard and any point during development, and the resulting behavior is updated.

    Sorry about "ranting" against Wizards in a blog entry celebrating something which is clearly a step forward. This is just a small warning of caution before we fill the Tools menu with wizards generating streams of code for the user to manage. And besides, I haven't actually tried this feature so perhaps it doesn't have the warts I am describing - I'm just weary of wizards in general.

  • Geertjan Monday, May 1, 2006
    "What if you suddenly decide you want to change something?" Use code completion and all the other features that the NetBeans editor provides. Wizards, in the context of NetBeans IDE, are for creating things, not for maintaining them. In the case of the Action wizard, and all other module development wizards, you've got the added feature of being able to manipulate the entire system filesystem via the "this layer in context" node. I don't think wizards should do more than they're currently doing and the wizards that I've blogged about here fit within that paradigm -- they serve the purpose of CREATING artifacts that conform to the Java EE 5 spec.
  • Michael Kovacs Monday, May 1, 2006
    This is really cool after I overcame my J2EE mindset of creating an EJB module and a Web module. Unfortunely if you create an EJB module and define your entities there the project structure doesn't allow visibility from your webapp.

    Once I came back here and realized that you'd just created a webapp I did the same and all was fine.

    By the way there's a UI bug in the generated create() method.
    the line:

    addMessage("Customer was successfully created.");

    appears after the catch clause in all generated controller classes. Should probably put that inside the try after the commit() call.
  • Jonathan Bruce Monday, May 1, 2006
    Forgive me for being slightly out of the loop here, this is ready and working today? If so, I'll definitly give this a look...
  • Geertjan Tuesday, May 2, 2006
    Jonathan, the answer is "yes". Just go to www.netbeans.org and then to the download page and get a daily build for the upcoming 5.5 release.

    Michael, yes, I can understand someone first going to create a J2EE application, or an EJB module, but neither of those are needed for this scenario. Great. And thanks for the other comments about the UI bug. I'll pass it on to Those Who Can Fix It.

  • Thomas Wednesday, May 3, 2006
    hey, this looks great. But after reading Tor's comment, I also have a question about mainaining the code: (I'm probably going to look like a total newbie here, well well..:)
    Lets say you generate some classes from a set of tables. Later on you need to add 1 or more fields to a table in the DB. Is there a way to "re-sync" the classes in Netbeans with the DB? (other than deleting the classes and running the wizard again?) This also goes for deleting fields..
    What will be the preffered way of maintaining DB<->Java persistence classes in NB 5.5? (That is, after you have run the wizards..)
    Obviously you can make the changes in the DB, and then manually make them in the persistence classes, but is it possible to do this another way?
  • Geertjan Wednesday, May 3, 2006
    Hi Thomas, if you look at my blog entry for today, you'll see that even people in Johannesburg are asking the question you're asking (and they're not all newbies at all). I get the feeling that something like a "resynchronize" function is needed, and I wouldn't be surprised if popular demand won't make that happen!
  • John Stevenson Wednesday, May 3, 2006
    There is a menu entry called "Recapture Schema from Database", which may help you keep some consistency between your model and database changes.
    If you look in the Configuration Files directory, you can see the database schema. Right click on the schema and there is the option.
  • Pavel Buzek Thursday, May 4, 2006

    I am kind of responsible for a number of these issues mentioned here :-) so I will try to respond.

    Tor: I am aware of the problem with round trip. I think there are several ways to solve this. First, there are two items in component palette for JSF: JSF Table and JSF Form. These generate code snippets with the dataTable or form. This should help if you add a column and want to change just the JSF. Second, there is EL code completion. Third, I agree that a more automatic regeneration would be nice and I will think about it for future.

    Michael Kovacs: The UI bug you mentioned is already fixed in daily builds. Error messages are also displayed with different color then info. Thanks for rlubke who suggested a fix in issue 75653.

    The problem with EJB: if you add the EJB module to classpath of your web module you should see the entity beans (unless there is a bug). But there is not really any benefit in putting entity beans into an EJB module if you have everything else in web module (persistence.xml, JSF). It would be nice to have an alternative version that would generate EJB session facades, maybe even with SEAM. But this is for future.

    Thomas: same as in the JSF wizard - at this point you can either delete the entity classes and generate again or you can use the Java editor to add fields for the columns you just added into DB. If you add a field in the Java editor it will offer you code completion for DB columns for @Column annotation. Better support for synchronization is definitely in our plans for next release. For entity classes from DB the reason why we do not have it was a time restriction more then anything else.

  • Michael Davis Friday, May 5, 2006
    Hello - When I right click on my application I do not see this choice <<Entity Classes from Database>>. Are you using a non-free version of the application to do this task? How do I enable that choice for my environment?
    I looked in the help document a little bit but could not easily find a reference to this menu item. I would have thought if I entered the menu choice text in the help search, I would be able to find a relevant instruction page.
    Thanks for your time,
    Michael A. Davis
  • Alex Lam Friday, May 5, 2006


    Michael Kovacs: When you say "non-free version of the application", you don't mean NetBeans IDE, do you?

  • Geertjan Friday, May 5, 2006
    Michael, you confusion is understandable. The menu items referred to here are in the 5.5 release (which hasn't been released yet, but of which development builds are already available on netbeans.org). And the reason why you found no help topics on these features is because the features are so new that they haven't been documented yet, but they will of course be documented by the time the 5.5 IDE is released!

    Pavel, thanks for inserting your useful responses.

  • Steve Nelson Friday, May 5, 2006
    FYI for all. If you do not see your persistence classes when creating a "JSF Pages from Entity Class", try switching your projects properties to "Source Level" 1.5.. Then try and create the page.
  • godfrey Friday, May 5, 2006
    Hello Geertjan,
    Nice post I would really like to combine this with the AJAX JSF Components I am building. This will show how powerful NetBeans is.
    Checkout my tutorial:
  • Keith Garrod Friday, May 5, 2006
    I tried this with the 5.5 Preview. The 'Entity classes from database' and 'JSF pages from entity classes' menu options did not appear on the Project's context menu, but I found them in Add->New File/Folder. I got the project to deploy successfully and the welcome page opens, but when I try to access a table I get an error: "#{item.Cannot Detect @Id Property}".
    Any ideas?
  • Geertjan Saturday, May 6, 2006
    Godfrey, that looks & sounds great!!! Wow, even with voice over. I'm at Amsterdam airport right now, but will look at it more closely when I get back in the office.

    Keith, please check that you have the source level set to "1.5" in the project's Project Properties dialog box, as pointed out by Steve Nelson above, because it seems that your annotations are not being interpreted correctly.

    Steve, thanks for the tip!

  • tfrg Wednesday, July 26, 2006
    cbn b
  • Maavilja Wednesday, August 2, 2006
    I downloaded the new 5.5 beta2 with GlassFish (sjsas_pe-9_0-nb-5_5-beta2-bin-win.exe). I then created the entity-classes for all tables in the sample database that comes with Derby. Curiously some tables Web -GUI works, while some hyperlinks cause a Null-pointer error.
    This happens because a generated method getProductController() tries to access the key "product" in the following:
    ProductController pc = (ProductController) FacesContext.getCurrentInstance().
    and this returns null.
    Any ideas? Most of the hyperlinks work ok.
    - maavilja
  • guest Saturday, August 5, 2006
  • Carl Smith Tuesday, September 19, 2006
    I am new to Java. I come from a Cobol Programming
    backround (12yrs.) I need help. I am using
    NetBeans 5.0. I need to see sample codeing on how
    to open, (1) Read & update a Database, also how to (2) Read a Database & extract names into a list box of a JFrame that I have created. (3)I also need to extract this info for a specific period, so I need to use a calendar (date picker), so a date range can be input.(4) I have created a Print button(radio button) and I need it to Display on screen or Write to a Printer. Please help.
  • Geertjan Wednesday, September 20, 2006
    You don't need help with NetBeans. You need help with Java. You should join a Java mailing list.
  • Geertjan Wednesday, September 20, 2006
    This should help you with your database-related questions:
  • Carl Smith Wednesday, September 20, 2006
    Thanks Geertjan ur help is appreciated. I have looked at that site and have printed the docs. I dont have an email address just yet. What do I do about the Date Picker. Do I have to purchase it, & how do I get the JButton to Display output on screen or write to printer. What site do i go to for this.
    NB. I do know how to use the setVisible & the System.out.println commands.
  • Geertjan Wednesday, September 20, 2006
    For a datepicker, maybe you can use Kai Toedter's JCalendar (http://www.toedter.com/en/jcalendar/index.html). For general questions on Java, use the Sun Developers Online Community mailing lists and forums:
  • Carl Smith Wednesday, September 20, 2006
    Thanks once again for being so helpful & patient
    I will check those sites now.
  • George de la Torre Sunday, September 24, 2006
    Creating seperate EJB and Web modules should be a common activity with JEE development. I'm starting to use NetBeans from being a JBuilder user for many years. Does NetBaens support building JEE applications by reusing modules? For example, I usually create one EJB modules and reuse it with different projects like multilple Web apps, Swing, Web Services, etc.
  • Geertjan Sunday, September 24, 2006
    Yes, you can first create an EJB module and then later attach it to a J2EE application.
  • bogi Saturday, September 30, 2006
    I can not see my persistence classes when I creating a "JSF Pages from Entity Class", I switched my projects properties to Source Level 1.5 but still can not see persistence classes.
    I use Net Beans 5.5 beta2 and jdk1.5.0_04
  • Geertjan Saturday, September 30, 2006
    Please describe step by step the things you did, starting from the very beginning, starting from the very first step.
  • bogi Saturday, September 30, 2006
    I make persistence unit and it work. I see my persistence classes and I created a JSF Pages from Entity Class, but when I deployed and run he report error:
    org.apache.jasper.JasperException: Exception in JSP: /jsf/tblartikli/List.jsp:11
    8: <title>List Tblartikli</title>
    9: </head>
    10: <body>
    11: <f:view>
    12: <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
    13: <h1>Listing Tblartiklis</h1>
    14: <h:form>
    and more...
  • Geertjan Saturday, September 30, 2006
    Please attach the error message to an e-mail and send it to geertjan.wielenga@sun.com
  • Joshua Smith Sunday, October 15, 2006
    I'm trying to work through your example but I keep getting the following error when it tries to compile my project after doing executing the Entity Classes from Database command:
    /Users/josh/Documents/Projects/Salmon2/src/java/salmon2/Authors.java:28: cannot find symbol
    symbol : method query()
    location: @interface javax.persistence.NamedQuery
    @NamedQuery(name = "Authors.findById", query = "SELECT a FROM Authors a WHERE a.id = :id"),
    I'm using Netbeans 5.5 Release candiate 1, Glassfish, Derby and Java 5 on Mac OS X. I created a sample database that stored information about authors in it. Any ideas?
    Joshua Smith
  • Geertjan Sunday, October 15, 2006
    Hi Josh, I don't know what's the reason for your problem. I recommend you write to nbusers@netbeans.org and probably someone who knows the answer will read your question.
  • mike Thursday, November 16, 2006
    How do you add java ee5 to netbeans, as i have downloaded and installed java ee5 without jdk (is this a problem?)
    Netbeans does not show the menu with 'jsf pages from entity classes', as you have in the second screenshot after the table, (here ....................http://blogs.sun.com/geertjan/entry/the_best_feature_of_the) what am I doing wrong? help......
  • rajeev Saturday, December 30, 2006
    I see the 'JSF Pages from entity class' when I create a 'web application' project and not while creating 'Visual Web Application'. Is there a reason for it? Is it possible to create 'JSF Pages from entity class' within 'Visual Web Application' project?
  • Geertjan Sunday, January 7, 2007
    Try this tutorial, rajeev: http://www.netbeans.org/kb/55/vwp-inserts_updates_deletes.html
  • Dave Wednesday, February 7, 2007
    Building entity classes from database doesn't seem to fill out @column annotation properties other than name and nullable. Is there any way to get it to fill out others (e.g. length, which I think is quite important!)
    Thanks, Dave.
  • Reiner Friday, February 16, 2007
    I do not see this choice Entity Classes from Database I try to follow the example at http://www.dmcmis.com/podcast/eapp-movil/player.html
    I am using NetBeans 5.5 netbeans-5_5-windows an JBoss App Sever 4.0
    Any help?
  • xirtna Thursday, March 15, 2007
    I dont seem to see 'Entity Classes from Databases' on right clicking the Web App Project , any reasons why so ?
    I have included the JSF framework in the project but still I cant see this option.
  • Geertjan Thursday, March 15, 2007
    Maybe not available there, what you see there are things you've recently selected. So look in the New File wizard instead.
  • xirtna Thursday, March 15, 2007
    Oh ok, thanks got it.
  • Marc Wednesday, March 28, 2007
    Is is possible to create an entity class from a view rather than a table? If I create a dbschema that includes a view, the view is not displayed when I try to create an entity class via 'Entity Classes frmo Database'.
    using nb 5.5.1 Beta
  • vignesh Monday, April 9, 2007
  • R Wednesday, May 16, 2007
    Same problem as xirtna, can you generate the ejb from a view? I'm moving from JDeveloper and that can do so, from the same database.
  • Geertjan Wednesday, May 16, 2007
    Hi R, good question, but I don't know the answer. Write to nbusers@netbeans.org, someone there should be able to help.
  • Stefan Wagner Tuesday, May 22, 2007
    I can't seem to find the JSF pages from Entities wizard anywhere. Neiter in 5.5 release or the 6.0 preveiew. Where has it gone?
  • Geertjan Tuesday, May 22, 2007
    Did you look in the New File wizard?
  • Andres Wednesday, May 23, 2007
    I'm trying to follow these steps using MySQL as the database, but i keep getting "Unable to find the driver" when i select the MySQL datasource...
    The driver is registered on Netbeans so i don't know what the problem is...
  • jhandal Monday, June 4, 2007
    How come Netbeans can be complicated when
    it comes to basic?
    A POJO Java Application trying dependency injection from a Stateless bean?
  • Heraldo Carneiro Monday, June 25, 2007
    Hi Geertjan,
    I am trying to create JSF pages from entity classes in an EJB module, but NetBeans doesn't see any of the entity classes in the EJB module, nor does it see the persistence unit. Would you know to do this? Thanks in advance.
  • guest Tuesday, July 3, 2007
    Great stuff, Helpful indeed
  • Erik Thursday, September 20, 2007

    Hmm, I wonder: why is this feature dropped for netbeans 6?

  • Geertjan Thursday, September 20, 2007

    Simply not enough time to up date it to the 6.0 release because changes to the editor meant that various parts of this feature would need to be redone. Planned to do so after 6.0 is released.

  • juan Friday, September 21, 2007

    do you knonw why my netbeans 5.5.1 (running at linux) do not show me the option "Entity Classes From Database ?

    tks !

  • Geertjan Friday, September 21, 2007

    I don't know, very strange. I would write to nbusers@netbeans.org if I were you.

  • Dan Monday, October 1, 2007

    A big, big bummer this feature was dropped in 6.0... :( It \*was\* one of the best features of the IDE to get a CRUD app off the ground quickly. Very disappointing.

  • alex Wednesday, October 24, 2007

    As per pos by jhandal, does anybody know how to create JSF pages from entity classes in an EJB module ?

    Do you end up with 1 or 2 persistent units ?

  • Geertjan Wednesday, October 24, 2007

    I recommend that you write to nbusers@netbeans.org with this question.

  • Dan Thursday, February 21, 2008

    This was one of my favorite NB5.5 features, I'm disappointed it got dropped. I guess if you want this feature back in NB6 we should vote for it here.


  • Geertjan Thursday, February 21, 2008

    Looks like it will be back in 6.1.

  • Aashish Sabharwal Friday, April 4, 2008

    i want to retrieve data from MySQL 5.0 using Netbeans 5.5

    Please guide me.

  • Geertjan Friday, April 4, 2008

    Write to nbusers@netbeans.org.

  • AnhKhoa Saturday, July 11, 2009

    @Geertjan : I'm trying to follow these steps using MySQL as the database, but i keep getting "Unable to find the driver" when i select the MySQL datasource... The driver is registered on Netbeans so i don't know what the problem is...

    I has the same problem, has someone fixed it ?

  • Richard Blaha Thursday, December 10, 2009

    Geertjan. This is a great article for way back in NB 5.5. I have been learning to use this today with NB 6.7.1.

    I have my Entities in an existing project. I created a new project to be separate from the one the entities are in.

    1. I add the project with the entities to my library.

    2. I create a Persistence unit in my new project with the same name as the one in the project with the entities.

    3. A add Toplink Essentials to my new project.

    4. I use the wizard 'JSF Pages from Entity Classes...' and all appears to work great.

    5. I Clean and Build, then Run the new project. When I click on a link to 'Show All Table Items' I get a NullPointerException in the code creating the EntityManager.


    private UserTransaction utx = null;

    @PersistenceUnit(unitName = "PersistPU")

    private EntityManagerFactory emf = null;

    public EntityManager getEntityManager() {

    return emf.createEntityManager(); // NullPointer here.


    Any ideas? Thank you.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.