-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate 5: generator class="sequence" not working anymore
PostPosted: Tue Dec 29, 2015 2:43 pm 
Newbie

Joined: Fri Aug 01, 2014 5:54 am
Posts: 13
Location: Brazil
I've always used this in Hibernate 4.3.x:
Code:
<id name="id" column="MY_COLUMN">
   <generator class="sequence">
      <param name="sequence">MY_SEQUENCE</param>
   </generator>
</id>

I migrated to Hibernate 5, and now the query is not referencing my mapping. Here is the SQL that is always generated no matter what sequence I reference:
Code:
select
  hibernate_sequence.nextval
from
  dual

Obviously, the result of this is: "The sequence doesn't exist"

The Hibernate 5.0 Migration Guide says:
Quote:
Deprecated org.hibernate.id.SequenceGenerator and its subclasses

Does it have anything to do with this deprecation?


Top
 Profile  
 
 Post subject: Re: Hibernate 5: generator class="sequence" not working anymore
PostPosted: Wed Dec 30, 2015 2:04 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You have to options:

1. You set the hibernate.id.new_generator_mappings configuration property to false and switch back to the old identifier generators
2. You change the mapping as follows:

From this:

Code:
<generator class="sequence">
    <param name="sequence">MY_SEQUENCE</param>
</generator>


to:

Code:
<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
    <param name="optimizer">none</param>
    <param name="increment_size">1</param>
    <param name="sequence_name">MY_SEQUENCE</param>
</generator>


Top
 Profile  
 
 Post subject: Re: Hibernate 5: generator class="sequence" not working anymore
PostPosted: Wed Dec 30, 2015 7:53 am 
Newbie

Joined: Fri Aug 01, 2014 5:54 am
Posts: 13
Location: Brazil
It's quite a change not to be documented anywhere. I guess you won't document anything on legacy XML mappings.

It must be something related to version 5.0 because when I was using version 4.3 I had hibernate.id.new_generator_mappings already set to true and it worked fine.

Thanks.


Top
 Profile  
 
 Post subject: Re: Hibernate 5: generator class="sequence" not working anymore
PostPosted: Wed Dec 30, 2015 8:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I think you should open a Jira issue for this because apart from the enhanced identifiers which have been changed and documented, the old XML definitions are not backward compatible like the annotation ones.

Post a link to this discussion to.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.