2012-01-25 8 views
1

私はderbyデータベースを埋め込んでおり、私はjpaで作業しています。これは私のpersistence.xmlです。apache derby + jpa

<?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="pers"> 

     <class>entities.Leverancier</class> 
     <class>entities.Prijsproduct</class> 
     <class>entities.Product</class> 


    </persistence-unit> 
</persistence> 

この変更を加えるには、どうすればよいですか?私は今、自分のコードを実行すると、私は次を得る:

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named pers 
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) 
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33) 
at test.Test.main(Test.java:19) 
+0

あなたの持続性プロバイダは何ですか? –

+0

どこで見つけることができますか? – user999379

+1

JPAランタイムプロバイダ(Hibernate、EclipseLinkなど)として何を使用しますか? 'persistence.xml'で言及する必要があります。 –

答えて

2

あなたpersistence.xmlが正しくありません。以下のサンプルを見てください:

<persistence-unit name="MyAppPU" transaction-type="RESOURCE_LOCAL">  
    <!-- This is where you mention your JPA runtime provider e.g. it's EclipseLink here --> 
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>  

    <class>mypkg.MyEntity</class> 

    <properties> 
     <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/my_schema"/> 
     <property name="javax.persistence.jdbc.password" value="pass"/> 
     <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/> 
     <property name="javax.persistence.jdbc.user" value="user"/> 
    </properties> 

</persistence-unit> 

また、あなたはクラスパスに(ダービークライアントJARと一緒に)あなたのJPAプロバイダのjarファイルを置くことを確認する必要があります。

+0

org.eclipse.persistence.jpa.PersistenceProvider どのjarファイルですか? – user999379

+0

ここからダウンロードできます:http://www.eclipse.org/eclipselink/downloads/ –

+1

@ user999379:JPA、EclipseLink、Derbyを使い始めるのに役立ちます:http://www.vogella.de/ articles/JavaPersistenceAPI/article.html#installation –

関連する問題