Hibernate could not fetch the SequenceInformation from the database

前端 未结 4 1497
抹茶落季
抹茶落季 2020-11-30 09:58

I have recently updated hibernate in my application to 5.4.4.Final. And now, I have faced with the following exception during deployment.

ERROR [org.hibernat         


        
4条回答
  •  粉色の甜心
    2020-11-30 10:58

    You simple used the dafault MAX_VALUE of a sequence, which is too high for the Java LONG datatype.

    Fortunatelly you may any time reset the MAX_VALUE with ALTER SEQUENCE to a lower number that will cause no problems.

    Example

    CREATE SEQUENCE SEQ_TEST START WITH 1 INCREMENT BY 1 NOCYCLE;
    
    
    select MAX_VALUE from ALL_SEQUENCES where SEQUENCE_NAME = 'SEQ_TEST';
    
     MAX_VALUE
    ----------
    9999999999999999999999999999
    
    
    ALTER SEQUENCE SEQ_TEST
      MAXVALUE 9223372036854775807;
    
    select MAX_VALUE from ALL_SEQUENCES where SEQUENCE_NAME = 'SEQ_TEST';
    
     MAX_VALUE
    ----------
    9223372036854775807
    

    and BTW

    it looks strange that hibernate tries to read metadata about all sequences, not only about used in my application.

    Hibernate uses select * from all_sequences as an Oracle Dialect to get the sequence information. Note that ALL_SEQUENCES does not mean all existing sequences, but all sequences, that your Hibernate database user (DBUSER from the connection pool) is granted to use - which is of course absolute correct.

提交回复
热议问题