|
[
Permalink
| « Hide
]
Steve Ebersole added a comment - 29/Aug/08 09:49 AM
The setting to control this is 'prefer_entity_table_as_segment_value'
I don't think prefer_entity_table_as_segment_value works with Hibernate Annotations.
In my entity I have: @Id @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.enhanced.TableGenerator", parameters = { @Parameter(name = "optimizer", value = "pooled"), @Parameter(name = "initial_value", value = "1"), @Parameter(name = "increment_size", value = "10"), @Parameter(name = "prefer_entity_table_as_segment_value", value = "true") }) @GeneratedValue(generator = "idGenerator") @Column(name = "id") private Integer id = null; But in the hibernate_sequences table, there's only one row with name "default" and all the entities use the next_val of that. Please advise if you want a JIRA separate issue for this. Thanks, Drew BTW, I'm using Hibernate 3.3.1.GA with Hibernate Annotations 3.4.0.GA
I have tests showing this works w/o annotations, and just looked at the code for how annotations deals with this and I do not see any problems with it. Please make *sure* you are using the Hibernate Core version you think you are using
Steve,
I'm sure Hibernate versions are correct since: 1) I use Ivy to download the correct versions of libraries from JBoss Maven repository 2) As a workaround I created my own custom id generator that extends TableGenerator (com.foo.bar.IDGenerator) and all it does is it overrides the configure method as: @Override public void configure(final Type type, final Properties params, final Dialect dialect) throws MappingException { params.put("optimizer", "pooled"); params.put("initial_value", "1"); params.put("increment_size", "10"); params.put("prefer_entity_table_as_segment_value", "true"); super.configure(type, params, dialect); } and in my entity I have: @Id @GenericGenerator(name = "idGenerator", strategy = "com.foo.bar.IDGenerator") @GeneratedValue(generator = "idGenerator") @Column(name = "id") private Integer id = null; and things work per spec. I was worried I wasn't using the annotations correctly that's why I commented to this JIRA in the first place. This is really strange. cheers, Drew |
|||||||||||||||||||||||||||||||||||||||||||||