- In Netbeans 7.2 create a new Java Application Project
- Add a connection to your database in Services tab –>Databases
- Copy all JPA entity classes in your project (in correct package)
- In newly created java app project right click on “Source Packages” –>New –>(Other)->Persistence Unit
- In New Persistence Unit dialog:
- Persistence LIbrary = Hibernate (JPA 1.0) (I tried with hibernate 4.1.9 and jpa 2 but is not working)
- Database connection = chose your db connection
- Table generation strategy = none
- Edit your persistence.xml
- In design tab –> Include Entity Classes –> add all of them
- In the source tab –> add the hibernate.dialect property e.g.
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
- Right click on your project and in Build –>Packaging->select Copy Dependency Libs (this will create a lib folder with all you need in the dist folder)
- Build your project
- Right click on your project and in Build –>Packaging->deselect Copy Dependency Libs (this will create your jar without references to other jars – perfect for squirrelsql)
- Build your project again
- In Squirrel File –> Global Preferences –> Hibernate: create a new configuration
- With “Add classpath entity” button:
- add jars for your jdbc driver
- add all jars in from your_java_app/dist/lib
- add your exported java app jar from dist folder
- select call … persistence-unit and complete persistence-unit name
- Select Run Hibernatate in SQuirreL’s Java VM
- Hit Apply Changes to this configuration and OK
After you’re connected to your db in the Hibernate tab is all the magic