Note that there are some explanatory texts on larger screens.

plurals
  1. POData Not inserting into Database JPA+Hibernate
    text
    copied!<p>actually I have created Entity Beans which are used to create tables in mysql database, everything is working fine with transaction classes using entityfactory.</p> <p>Now I need this functionality...when I deploy the EAR file in application sever JBOSS..it have to check whether the tables are existing in the database or not..if they are not present..it have to create the tables automatically..of course I have specified this function hibernate.hbm2ddl.auto=update in persistence.xml..but still not creating any tables which are not present in the database and not throwing any error also when ever I run the application server its creating only mysql default tables..but not the developed ones and here I am give my code:</p> <pre><code>package com.ernst.persistenceImpl.beanImpl; import com.ernst.persistenceAPI.beanAPI.NrKreiseBeanAPI; import com.ernst.persistenceAPI.localBeanAPI.NrKreiseLocalBeanAPI; import com.ernst.persistenceAPI.remoteBeanAPI.NrKreiseRemoteBeanAPI; import javax.persistence.Entity; import javax.persistence.Table; import javax.persistence.Id; import javax.persistence.Basic; import java.io.Serializable; @Entity @Table(name = "NR_KREISE") public class NrKreiseBean implements NrKreiseBeanAPI, NrKreiseLocalBeanAPI, NrKreiseRemoteBeanAPI, Serializable { @Id private int nr_kreise_id; @Basic private int fk_nr_typ; @Basic private int data_ref_von; @Basic private int data_ref_bis; @Basic private int data_ref; @Basic private int msg_ref_von; @Basic private int msg_ref_bis; @Basic private int msg_ref; @Basic private String desc; public int getNr_kreise_id() { return nr_kreise_id; } public void setNr_kreise_id(int nr_kreise_id) { this.nr_kreise_id = nr_kreise_id; } public int getFk_nr_typ() { return fk_nr_typ; } public void setFk_nr_typ(int fk_nr_typ) { this.fk_nr_typ = fk_nr_typ; } public int getData_ref_von() { return data_ref_von; } public void setData_ref_von(int data_ref_von) { this.data_ref_von = data_ref_von; } public int getData_ref_bis() { return data_ref_bis; } public void setData_ref_bis(int data_ref_bis) { this.data_ref_bis = data_ref_bis; } public int getData_ref() { return data_ref; } public void setData_ref(int data_ref) { this.data_ref = data_ref; } public int getMsg_ref_von() { return msg_ref_von; } public void setMsg_ref_von(int msg_ref_von) { this.msg_ref_von = msg_ref_von; } public int getMsg_ref_bis() { return msg_ref_bis; } public void setMsg_ref_bis(int msg_ref_bis) { this.msg_ref_bis = msg_ref_bis; } public int getMsg_ref() { return msg_ref; } public void setMsg_ref(int msg_ref) { this.msg_ref = msg_ref; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } } </code></pre> <p>Persistence.xml file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;persistence 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_1_0.xsd" version="1.0"&gt; &lt;persistence-unit name="DefaultDS" transaction-type="JTA"&gt; &lt;jta-data-source&gt;java:/DefaultDS&lt;/jta-data-source&gt; &lt;class&gt;com.ernst.persistenceImpl.beanImpl.NrKreiseBean&lt;/class&gt; &lt;properties&gt; &lt;property name="jboss.entity.manager.factory.jndi.name" value="persistence-units/DefaultDS" /&gt; &lt;property name="hibernate.ejb.cfgfile" value="WEB-INF.classes.META-INF.hibernate.cfg.xml" /&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt; &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /&gt; &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/lagerstandnew" /&gt; &lt;property name="hibernate.connection.username" value="root" /&gt; &lt;property name="hibernate.connection.password" value="sekhar" /&gt; &lt;!-- Scan for annotated classes and Hibernate mapping XML files --&gt; &lt;property name="hibernate.archive.autodetection" value="class, hbm" /&gt; &lt;property name="hibernate.hbm2ddl.auto" value="create" /&gt; &lt;!-- SQL stdout logging --&gt; &lt;property name="hibernate.format_sql" value="true" /&gt; &lt;property name="hibernate.show_sql" value="true" /&gt; &lt;property name="use_sql_comments" value="true" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>Can any one please give me an idea how to do this or please tell me if I have done anything wrong in above files.</p> <p>Thanks in Advance.</p> <p>Best Regards, Raja.</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