Spring + hibernation integration missing Table "table_name" missing

I integrate spring with hibernate, I use the dropwizard configuration files, because: the persistence file has configuration files in the resource folder, without any problems loading xml files. There is a problem with the table found. The persistence.xml file as:

<persistence-unit name="bfm" transaction-type="RESOURCE_LOCAL" > <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>com.bcits.parkingmanagement.model.User</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <!-- Configuring JDBC properties --> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/anuj" /> <property name="javax.persistence.jdbc.user" value="root" /> <property name="javax.persistence.jdbc.password" value="root" /> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> </persistence-unit> </persistence> 

In spring app config xml as: only sleep configuration is displayed there

 <context:annotation-config /> <context:component-scan base-package="com.bcits.parkingmanagement.model" /> <jdbc:embedded-database id="dataSource" type="HSQL" /> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceXmlLocation" value="classpath:spring/persistence.xml" /> <property name="dataSource" ref="dataSource"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> 

Missing user table

  javax.persistence.PersistenceException: [PersistenceUnit: bfm] Unable to build EntityManagerFactory org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) ... 18 more Caused by: org.hibernate.HibernateException: Missing table: user 

Please help me how can I resolve this error. I want the spring configuration with hibernate.I that it connects to the database but cannot find the table. The table name and colume name are exactly the same. The database name is also correct and without problems with the username and password of the database.

+5
source share
1 answer
 User model is: Here User is model name and user is table which have two column one is user_id and user_name. Issue is that i had used user instead of User in query. Because User is model name and user is table name .Correct model is given below @NamedQueries({ @NamedQuery( name="getUserName" , query="select name from User") }) @Entity @Table( name ="user") public class User { @Id @Column( name="user_id") private int id; @Column( name="user_name") private String name; //getter setter } 
+4
source

Source: https://habr.com/ru/post/1245477/


All Articles