Note that there are some explanatory texts on larger screens.

plurals
  1. POIn Spring MVC 3.0.5 controller JPA entity not getting persisted to the database
    text
    copied!<p>In the code below, persist() returns w/o an exception but the entity is not stored in the database. </p> <pre><code>@RequestMapping(method = RequestMethod.POST) public String form() { EntityManager em = this.emf.createEntityManager(); TaxRates t = new TaxRates(); t.setCountry("US"); // set more properties em.persist(t); em.close(); ... } </code></pre> <p>persistence.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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"&gt; &lt;persistence-unit name="TT-SpringMVCPU" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt; ... &lt;class&gt;com.sajee.db.TaxRates&lt;/class&gt; &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt; &lt;properties&gt; &lt;property name="javax.persistence.jdbc.url" value="jdbc:jtds:sqlserver://localhost:1234/mydb"/&gt; &lt;property name="javax.persistence.jdbc.password" value="Password1"/&gt; &lt;property name="javax.persistence.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/&gt; &lt;property name="javax.persistence.jdbc.user" value="sa"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>I don't need any transaction support or any fancy enterprise feature support. I simply want to create an entity and save it to the database. </p> <p>Where am I going wrong? </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