Why is a sequence named hibernate_sequence being created with JPA using Hibernate with the Oracle 10g dialect?

前端 未结 3 1934
太阳男子
太阳男子 2021-02-15 12:46

All my entities use this type of @Id

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = \"MYENTITY_SEQ\")
@SequenceGenerator(name =         


        
3条回答
  •  旧时难觅i
    2021-02-15 13:05

    I see the following code in org.hibernate.id.SequenceGenerator:

    public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
        ObjectNameNormalizer normalizer = ( ObjectNameNormalizer ) params.get( IDENTIFIER_NORMALIZER );
        sequenceName = normalizer.normalizeIdentifierQuoting(
                PropertiesHelper.getString( SEQUENCE, params, "hibernate_sequence" )
        );
        parameters = params.getProperty( PARAMETERS );
    
        if ( sequenceName.indexOf( '.' ) < 0 ) {
            final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
            final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
            sequenceName = Table.qualify(
                    dialect.quote( catalogName ),
                    dialect.quote( schemaName ),
                    dialect.quote( sequenceName )
            );
        }
        else {
            // if already qualified there is not much we can do in a portable manner so we pass it
            // through and assume the user has set up the name correctly.
        }
    
        this.identifierType = type;
        sql = dialect.getSequenceNextValString( sequenceName );
    }
    

    Where the third parameter of PropertiesHelper.getString(String, Properties, String) is the default property value.

    So I'm tempted to say that, somewhere, you have an Id not "properly" annotated. Maybe you should perform a little debugging session.

提交回复
热议问题