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

All my objects use this type of @Id

 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYENTITY_SEQ") @SequenceGenerator(name = "MYENTITY_SEQ", sequenceName = "MYENTITY_SEQ") @Column(name = "MYENTITY", nullable = false) private Long id; 

or

 @Id @Column(name = "MYENTITY") 

I found that an Oracle sequence named hibernate_sequence always created. Why is this so? And how can I avoid this?

I am using JPA1 with Hibernate 3 and dialect of Oracle 10g.

+7
java oracle10g orm hibernate jpa
source share
3 answers

I suspect this because I use Hibernate Envers, since I double-checked my entities, and they all have the correct @Id mappings.

-3
source share

HIBERNATE_SEQUENCE is used with a REVINFO entity to create revision numbers. If you want to use a different sequence, you must create your own revision object.

Help with this: http://docs.jboss.org/hibernate/envers/3.5/reference/en-US/html/revisionlog.html

+9
source share

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 ); } 

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

Therefore, I am tempted to say that somewhere you have Id not "correctly" annotated. You might need to do a little debugging session.

+4
source share

All Articles