[hibernate-dev] Hibernate ignores 'schema' attribute of @SequenceGenerator for Oracle sequences

Steve Ebersole steve at hibernate.org
Mon Aug 13 08:34:04 EDT 2012


Let's keep this on-list, thanks..

I think you are missing the point that 
'AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS' is a setting that 
*you* set.  It tells Hibernate which strategy it should use to map JPA 
generator annotations to org.hibernate.id.IdentifierGenerator 
implementations.  So its "always false" because you never set it to 
anything else...

@SequenceGenerator maps to either org.hibernate.id.SequenceHiLoGenerator 
(when flag is false) or org.hibernate.id.enhanced.SequenceStyleGenerator 
(when flag is true).  SequenceHiLoGenerator does *not* account for 
schema/catalog; SequenceStyleGenerator does.  That flag as false is 
legacy behavior.  Yes we could make SequenceHiLoGenerator (which is 
deperecated) properly account for schema/catalog.  But you could also 
enable to the new generator mappings.


On 08/13/2012 02:23 AM, mutaz kabbashi wrote:
> hi steve
>
> i mean the (USE_NEW_ID_GENERATOR_MAPPINGS) always = false for example
>
> if i create the following entity class
>
> package bugs.HHH_7232;
>
> import javax.persistence.*;
>
> @Entity
> @Table(name = "test", schema = "jaseadm")
>
> @SequenceGenerator(schema="hibernate_bug",
> name="applicantSignupSequence", sequenceName="seq_applicant_signup" )
> public class SeqTest {
>      @Id
>      @GeneratedValue(generator = "applicantSignupSequence",
>                      strategy = GenerationType.SEQUENCE)
>      private int id;
>
> }
>
> hibernate should use sequence from (hibernate_bug) schema but it
> doesn't because when hibernate checks
> (USE_NEW_ID_GENERATOR_MAPPINGS) consatnt @buildIdGenerator() method
> @org.hibernate.cfg.AnnotationBinder Class using the following variable
> (final boolean useNewGeneratorMappings =
> mappings.useNewGeneratorMappings() ;)  which always  returns false
>
> below is the body of useNewGeneratorMappings()
> method at org.hibernate.cfg.Configuration class
> @SuppressWarnings({ "UnnecessaryUnboxing" })
> 		public boolean useNewGeneratorMappings() {
> 			if ( useNewGeneratorMappings == null ) {
> 				final String booleanName = getConfigurationProperties()
> 					.getProperty( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS ); //problem
> 				useNewGeneratorMappings = Boolean.valueOf( booleanName );
> 			}
> 			return useNewGeneratorMappings.booleanValue();
> 		}
>
>
>
>
>
> On Sun, Aug 12, 2012 at 8:15 PM, Steve Ebersole <steve at hibernate.org> wrote:
>> Not following what you mean "'use new id generator mappings' is false all
>> the time".
>>
>> On Aug 12, 2012 3:40 AM, "mutaz kabbashi" <mutazhkabbashi at gmail.com> wrote:
>>>
>>> hi all
>>>
>>>      i am new here and  i  want  to contribute to hibernate so i
>>> started with simple bug (Hibernate ignores 'schema' attribute of
>>> @SequenceGenerator for Oracle sequences HHH-7232)
>>> (https://hibernate.onjira.com/browse/HHH-7232) , after i checked the
>>> code i found out  that when hibenate try to parse @SequenceGenerator
>>> annotation of Entity class it checks (USE_NEW_ID_GENERATOR_MAPPINGS )
>>> constatnt @[org.hibernate.cfg.AvailableSettings.java] which will be
>>> false  all the time so hibernate will not read the sequence schema .
>>>    so what is the best way to solve this problem
>>>
>>>
>>>
>>>    - Change USE_NEW_ID_GENERATOR_MAPPINGS value (could make problem
>>> with backward compatibility)
>>>
>>>   - create new constant
>>>
>>> - check @sequenceGenerator and get schema name  (if schema is present
>>> get schema name else schema name will be null )
>>>
>>> - any suggestion
>>>
>>> thank you
>>> _______________________________________________
>>> hibernate-dev mailing list
>>> hibernate-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev

-- 
steve at hibernate.org
http://hibernate.org


More information about the hibernate-dev mailing list