java - org.hibernate.id.enhanced.TableStructure - could not read a hi value -


i work spring mvc/ hibernate app , re-started after while again work on. time following errors,

javax.persistence.persistenceexception: org.hibernate.id.identifiergenerationexception: not read hi value - need populate table: hibernate_sequence     @ org.hibernate.internal.exceptionconverterimpl.convert(exceptionconverterimpl.java:147)     @ org.hibernate.internal.exceptionconverterimpl.convert(exceptionconverterimpl.java:155)     @ org.hibernate.internal.exceptionconverterimpl.convert(exceptionconverterimpl.java:162)     @ org.hibernate.internal.sessionimpl.firepersist(sessionimpl.java:787)     @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:765)     @ mobi.puut.database.walletinfodaohibernate.create(walletinfodaohibernate.java:65)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:333)     @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:136)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:213)     @ com.sun.proxy.$proxy39.create(unknown source)     @ mobi.puut.services.walletserviceimpl.createwalletinfo(walletserviceimpl.java:279)     @ mobi.puut.services.walletserviceimpl.lambda$generateaddress$0(walletserviceimpl.java:104)     @ mobi.puut.controllers.walletmanager$1.lambda$onsetupcompleted$0(walletmanager.java:105)     @ java.lang.iterable.foreach(iterable.java:75)     @ java.util.collections$synchronizedcollection.foreach(collections.java:2062)     @ mobi.puut.controllers.walletmanager$1.onsetupcompleted(walletmanager.java:105)     @ org.bitcoinj.kits.walletappkit.startup(walletappkit.java:325)     @ com.google.common.util.concurrent.abstractidleservice$2$1.run(abstractidleservice.java:54)     @ com.google.common.util.concurrent.callables$3.run(callables.java:95)     @ java.lang.thread.run(thread.java:748) caused by: org.hibernate.id.identifiergenerationexception: not read hi value - need populate table: hibernate_sequence     @ org.hibernate.id.enhanced.tablestructure$1$1.execute(tablestructure.java:142)     @ org.hibernate.id.enhanced.tablestructure$1$1.execute(tablestructure.java:126)     @ org.hibernate.jdbc.workexecutor.executereturningwork(workexecutor.java:55)     @ org.hibernate.jdbc.abstractreturningwork.accept(abstractreturningwork.java:34)     @ org.hibernate.resource.transaction.backend.jdbc.internal.jdbcisolationdelegate.delegatework(jdbcisolationdelegate.java:57)     @ org.hibernate.id.enhanced.tablestructure$1.getnextvalue(tablestructure.java:125)     @ org.hibernate.id.enhanced.noopoptimizer.generate(noopoptimizer.java:40)     @ org.hibernate.id.enhanced.sequencestylegenerator.generate(sequencestylegenerator.java:432)     @ org.hibernate.event.internal.abstractsaveeventlistener.savewithgeneratedid(abstractsaveeventlistener.java:105)     @ org.hibernate.event.internal.defaultpersisteventlistener.entityistransient(defaultpersisteventlistener.java:189)     @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:132)     @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:58)     @ org.hibernate.internal.sessionimpl.firepersist(sessionimpl.java:780)     ... 23 more org.hibernate.id.enhanced.tablestructure: 08/15/2017 13:48:27 - not read hi value - need populate table: hibernate_sequence exception in thread " starting" java.lang.illegalstateexception: org.hibernate.resource.jdbc.internal.logicalconnectionmanagedimpl@5e9059bd closed     @ org.hibernate.resource.jdbc.internal.abstractlogicalconnectionimplementor.errorifclosed(abstractlogicalconnectionimplementor.java:37)     @ org.hibernate.resource.jdbc.internal.logicalconnectionmanagedimpl.getphysicalconnection(logicalconnectionmanagedimpl.java:144)     @ org.hibernate.resource.jdbc.internal.logicalconnectionmanagedimpl.getconnectionfortransactionmanagement(logicalconnectionmanagedimpl.java:263)     @ org.hibernate.resource.jdbc.internal.abstractlogicalconnectionimplementor.rollback(abstractlogicalconnectionimplementor.java:116)     @ org.hibernate.resource.transaction.backend.jdbc.internal.jdbcresourcelocaltransactioncoordinatorimpl$transactiondrivercontrolimpl.rollback(jdbcresourcelocaltransactioncoordinatorimpl.java:239)     @ org.hibernate.engine.transaction.internal.transactionimpl.rollback(transactionimpl.java:100)     @ mobi.puut.database.walletinfodaohibernate.create(walletinfodaohibernate.java:71)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:333)     @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:136)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:213)     @ com.sun.proxy.$proxy39.create(unknown source)     @ mobi.puut.services.walletserviceimpl.createwalletinfo(walletserviceimpl.java:279)     @ mobi.puut.services.walletserviceimpl.lambda$generateaddress$0(walletserviceimpl.java:104)     @ mobi.puut.controllers.walletmanager$1.lambda$onsetupcompleted$0(walletmanager.java:105)     @ java.lang.iterable.foreach(iterable.java:75)     @ java.util.collections$synchronizedcollection.foreach(collections.java:2062)     @ mobi.puut.controllers.walletmanager$1.onsetupcompleted(walletmanager.java:105)     @ org.bitcoinj.kits.walletappkit.startup(walletappkit.java:325)     @ com.google.common.util.concurrent.abstractidleservice$2$1.run(abstractidleservice.java:54)     @ com.google.common.util.concurrent.callables$3.run(callables.java:95)     @ java.lang.thread.run(thread.java:748) 

i have few tables in database , hibernate_sequence table provided below,

enter image description here

i have seen suggested in forum fill hibernate_sequence table following , have done doesn't solve issue.

insert wallet.hibernate_sequence(next_val) values(0) 

i use java annotation based config , database connection provided below,

    @bean     public datasource datasource() {          drivermanagerdatasource datasource = new drivermanagerdatasource();         datasource.setdriverclassname("com.mysql.cj.jdbc.driver");          // datasource.seturl("jdbc:mysql://localhost:3306/wallet?createdatabaseifnotexist=true");         datasource.seturl("jdbc:mysql://localhost:3306/wallet");         datasource.setusername("testuser");         datasource.setpassword("testpassword");          return datasource;     }      properties hibernateproperties() {          properties properties = new properties(); //        properties.setproperty("hibernate.hbm2ddl.auto", "create-drop");         properties.setproperty("hibernate.dialect", "org.hibernate.dialect.mysql5dialect");         properties.setproperty("hibernate.id.new_generator_mappings", "false");         return properties;     } 

here pom use app,

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">      <modelversion>4.0.0</modelversion>      <groupid>com.puut.wallet</groupid>     <version>1.0-snapshot</version>     <packaging>war</packaging>     <artifactid>bitcoinwalletapp</artifactid>     <name>bitcoin wallet</name>      <build>         <resources>             <resource>                 <directory>src/main/resources</directory>                 <filtering>true</filtering>             </resource>             <resource>                 <directory>src/main/java</directory>             </resource>         </resources>     </build>      <parent>         <groupid>org.bitcoinj</groupid>         <artifactid>bitcoinj-parent</artifactid>         <version>0.14.4</version>     </parent>      <properties>         <spring.version>4.3.10.release</spring.version>         <spring.security.version>4.2.3.release</spring.security.version>     </properties>       <dependencies>          <!--crypto-currencies dependencies-->         <dependency>             <groupid>org.bitcoinj</groupid>             <artifactid>bitcoinj-core</artifactid>             <version>${project.parent.version}</version>         </dependency>          <!--spring dependencies-->         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-core</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-beans</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-context</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-jdbc</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-web</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-webmvc</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-test</artifactid>             <version>${spring.version}</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-orm</artifactid>             <version>${spring.version}</version>         </dependency>           <!--spring security dependencies-->         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-core</artifactid>             <version>${spring.security.version}</version>         </dependency>         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-web</artifactid>             <version>${spring.security.version}</version>         </dependency>         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-config</artifactid>             <version>${spring.security.version}</version>         </dependency>         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-taglibs</artifactid>             <version>${spring.security.version}</version>         </dependency>           <!--web api dependencies-->         <dependency>             <groupid>javax.validation</groupid>             <artifactid>validation-api</artifactid>             <version>release</version>         </dependency>         <dependency>             <groupid>commons-validator</groupid>             <artifactid>commons-validator</artifactid>             <version>1.6</version>         </dependency>         <dependency>             <groupid>com.google.guava</groupid>             <artifactid>guava</artifactid>             <version>18.0</version>         </dependency>         <dependency>             <groupid>org.slf4j</groupid>             <artifactid>slf4j-log4j12</artifactid>             <version>1.7.20</version>         </dependency>         <dependency>             <groupid>net.glxn</groupid>             <artifactid>qrgen</artifactid>             <version>1.3</version>         </dependency>         <dependency>             <groupid>javax.servlet</groupid>             <artifactid>javax.servlet-api</artifactid>             <version>3.1.0</version>             <scope>provided</scope>         </dependency>         <dependency>             <groupid>javax.servlet</groupid>             <artifactid>jstl</artifactid>             <version>1.2</version>         </dependency>           <!--testing , database dependencies incl. hibernate-->         <dependency>             <groupid>junit</groupid>             <artifactid>junit</artifactid>             <version>4.12</version>             <scope>test</scope>         </dependency>         <dependency>             <groupid>commons-dbcp</groupid>             <artifactid>commons-dbcp</artifactid>             <version>1.4</version>         </dependency>         <dependency>             <groupid>mysql</groupid>             <artifactid>mysql-connector-java</artifactid>             <version>6.0.6</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-core</artifactid>             <version>5.2.10.final</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-validator</artifactid>             <version>5.4.1.final</version>         </dependency>           <!-- jackson dependencies-->         <dependency>             <groupid>com.fasterxml.jackson.core</groupid>             <artifactid>jackson-core</artifactid>             <version>release</version>         </dependency>         <dependency>             <groupid>com.fasterxml.jackson.core</groupid>             <artifactid>jackson-databind</artifactid>             <version>release</version>         </dependency>         <dependency>             <groupid>javax.ws.rs</groupid>             <artifactid>jsr311-api</artifactid>             <version>1.1.1</version>         </dependency>     </dependencies> </project> 

here walletinfo pojo,

@entity @table(name = "wallet_info") public class walletinfo {      @id     @column(name = "id")     @generatedvalue(strategy = generationtype.auto)     private long id;      @notnull     @column(name = "name")     private string name;      @notnull     @column(name = "address")     private string address;      public long getid() {         return id;     }      public void setid(long id) {         this.id = id;     }      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public string getaddress() {         return address;     }      public void setaddress(string address) {         this.address = address;     } } 

whats issue here , how solve it?

if not maintaining sequence in database, use @generatedvalue(strategy = javax.persistence.generationtype.identity ) automatically maintain unique identification table.

javax.persistence.generationtype.identity

the identity option allows database generate unique primary key application. no sequence or table used maintain primary key information, instead, database pick appropriate, unique number hibernate assign primary key of entity. mysql, first lowest numbered primary key available in table in question chosen, although behavior may differ database database.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -