-->
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: Updating 3 to 5 -- hibernate_sequences column name changed?
PostPosted: Fri May 05, 2017 12:30 pm 
Newbie

Joined: Fri May 05, 2017 12:09 pm
Posts: 7
Hi,

I'm updating some old code from Hibernate 3 to 5.2. It appears that the column name in the table `hibernate_sequences` changed from `sequence_next_hi_value` to `next_val`. Is there a place I can control which column Hibernate looks for, with a global configuration setting?

Some details ... when inserting entities that use table ID generation, I get SQL errors with messages like: Unknown column 'tbl.next_val' in 'field list'

I see in the 5.2 User Guide, section 2.6.10 that the column in `hiberate_sequences` is called `next_val`, but in our DB it is `sequence_next_hi_value`.

The entity's ID property in Java looks like this:

Code:
@Id
@TableGenerator(name = "t_generator")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "t_generator")
private Long id;


thanks,
Rob


Top
 Profile  
 
 Post subject: Re: Updating 3 to 5 -- hibernate_sequences column name changed?
PostPosted: Fri May 05, 2017 1:23 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
The identifier generators have changed a lot. You might want to switch back to the old identifier generators as explained in this article.

Code:
<property name="hibernate.id.new_generator_mappings" value="false"/>


Also, you can control the table name and columns via the @TableGenerator annotation.

But then you should not use TABLE generator at all because it's bad for performance.


Top
 Profile  
 
 Post subject: Re: Updating 3 to 5 -- hibernate_sequences column name changed?
PostPosted: Fri May 05, 2017 2:35 pm 
Newbie

Joined: Fri May 05, 2017 12:09 pm
Posts: 7
Okay, thanks. I'm going to try that now.

vlad wrote:
Code:
<property name="hibernate.id.new_generator_mappings" value="false"/>



I assume that's in a hibernate.cfg.xml file, but my IDE seems to only allow the value to be nested in the element, so just wanted to double check.

Code:
<property name="hibernate.id.new_generator_mappings">false</property>


Top
 Profile  
 
 Post subject: Re: Updating 3 to 5 -- hibernate_sequences column name changed?
PostPosted: Fri May 05, 2017 2:45 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
Yes.That's how you should do it in hibernate.cfg.xml. I have you the persistence.xml way of doing it.


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.