Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenJPA creating EntityManager in code without persistence.xml, with properties
    text
    copied!<p>I need to create EntityManager in code without persistence.xml ... I have </p> <pre><code> props.put("openjpa.ConnectionURL", "jdbc:sqlserver://databasehost:3306; DatabaseName=dbname; selectMethod=cursor;create=true"); props.put("openjpa.ConnectionDriverName","com.mysql.jdbc.Driver"); props.put("openjpa.ConnectionUserName", "dbname"); props.put("openjpa.ConnectionPassword", "password"); props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema"); props.put("openjpa.Log", "DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"); props.put("openjpa.RuntimeUnenhancedClasses", "supported"); EntityManagerFactory factory = Persistence.createEntityManagerFactory("wp"); em = factory.createEntityManager(props); </code></pre> <p>..and when em = factory.createEntityManager(props) is called I get : </p> <pre> javax.persistence.PersistenceException: No persistence providers available for "wp" after trying the following discovered implementations: org.apache.openjpa.persistence.PersistenceProviderImpl at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:182) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:72) at dao.wp.WP_EMH.getCurrentEntityManager(WP_EMH.java:27) </pre> <p>I understand that there is no mention about something that is in persistence.xml represented by tag </p> <p>PROVIDER- org.apache.openjpa.persistence.PersistenceProviderImpl - /PROVIDER</p> <p>How should I add this to Properties? Or how to solve it? And my second question is that in persistence.xml are added classes of entities. How to solve this with properties?</p> <p>thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload