Extreme Java When vanilla Java is not enough

27Mar/090

NetBeans Platform + JPA + Derby embedded

If you want to use NetBeans Platform and JPA together, there's a great tutorial on NB's site. Unfortunatelly, it explains how to do it with an external database and using an external JAR for your entities.

If you want to have a entity module with your classes (instead of an external JAR and a library wrapper), no big deal - it works! You can follow GJ's tutorial, but you will create a module project instead and you will not have NB's wizards to help creating entity classes.

I also created a module install on my Derby wrapper, with this line:

FileUtil configRoot = FileUtil.getConfigRoot();
System.setProperty("derby.system.home",
    FileUtil.toFile(configRoot).getCanonicalPath());

This defines where Derby will create database files (user's dir, in this case).

BTW, if a "no suitable driver found" is thrown, you forgot to add a dependency between JPA wrapper (EclipseLink, TopLink, OpenJPA or Hibernate) and JDBC wrapper.