Note that there are some explanatory texts on larger screens.

plurals
  1. POCould not execute JDBC batch update How to solve this
    primarykey
    data
    text
    <p>I am doing a basic operation in Hibernate .I have an entity class with annotations and have a main class from where i am running the application.But its showing Could not execute JDBC batch update. this is my code..</p> <p>Entity Class</p> <pre><code>import javax.persistence.Entity; import javax.persistence.Id; @Entity public class UserDetails { @Id private int userId; private String userName; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } } </code></pre> <p>this is hibernate.cfg</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;!-- Database Connection setting --&gt; &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt; &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt; &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/hibernate&lt;/property&gt; &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt; &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt; &lt;property name="hibernate.connection.pool_size"&gt;2&lt;/property&gt; &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt; &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name="hbm2ddl"&gt;Create&lt;/property&gt; &lt;mapping class="org.jeet.dto.UserDetails"/&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <p>This is main class</p> <pre><code>import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.jeet.dto.UserDetails; public class HibernateTest { /** * @param args */ public static void main(String[] args) { UserDetails user = new UserDetails(); user.setUserId(1); user.setUserName("First user"); SessionFactory sessionFactory = new Configuration().configure() .buildSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction(); session.save(user); session.getTransaction().commit(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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