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 215812 - JPA 2 and Hibernate (Maven projects, but perhaps more general)
Summary: JPA 2 and Hibernate (Maven projects, but perhaps more general)
Status: RESOLVED DUPLICATE of bug 206120
Alias: None
Product: javaee
Classification: Unclassified
Component: Hibernate (show other bugs)
Version: 7.2
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-22 21:24 UTC by fommil
Modified: 2012-07-23 13:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fommil 2012-07-22 21:24:35 UTC
I always use Hibernate as my JPA2 provider - in both J2SE and J2EE.

However, the NetBeans support for Hibernate is very poor and the "Create Persistence Provider" or graphical editor for persistence.xml always insists that Hibernate only has JPA1 support.

Netbeans should support Hibernate as a JPA2 provider - if this means updating an ageing "Ant Library" then please do so.


Details follow...

My projects are all Maven based and the pom.xml entries amount to this (for a Derby backend)

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.1.5.SP1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.9.1.0</version>
            <scope>runtime</scope>
        </dependency>
        <!-- consider using C3PO and ehcache -->
        <dependency>
            <!-- a dependency of Hibernate, which is locally managed -->
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.6.6</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.6.6</version>
            <scope>runtime</scope>
        </dependency>


I like to keep my J2SE persistence.xml very sparse and load properties from a properties file at runtime, e.g. containing

hibernate.dialect = org.hibernate.dialect.DerbyDialect
hibernate.connection.driver_class = org.apache.derby.jdbc.EmbeddedDriver
hibernate.connection.url = jdbc:derby:MYDBNAME;create=true
hibernate.connection.charSet = UTF-8

with a persistence.xml that usually looks like

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="MyPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <!-- most properties are defined in jpa.properties -->
    <class>path.to.MyClass</class>
    <properties>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    </properties>
  </persistence-unit>
</persistence>
Comment 1 Sergey Petrov 2012-07-23 13:21:30 UTC
netbeans support hibernate as jpa2.0 provider and if library is manually added it should be used in persistence area. but bundled one is jpa1.0 hibernate and updating is another issue and is covered by 206120

*** This bug has been marked as a duplicate of bug 206120 ***
Comment 2 Sergey Petrov 2012-07-23 13:25:50 UTC
ok, I miss "maven" and all above I said was about ant project, I can't say yet if new library with hibernate with jpa2.0 support will work fine, please reopen if not or I'll try myself later too.