Issue Details (XML | Word | Printable)

Key: HHH-3454
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Steve Ebersole
Reporter: Steve Ebersole
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

Allow enhanced.TableGenerator to segment itself per entity as default

Created: 29/Aug/08 12:56 AM   Updated: 14/Nov/08 11:10 AM
Component/s: core
Affects Version/s: 3.3.0.SP1
Fix Version/s: 3.2.7, 3.3.1, 3.5

Time Tracking:
Not Specified


 Description  « Hide
Currently TableGenerator use a static string ("default" ) for its default segment column name. The implication is that all TableGenerators defined without specifying a segment value explicitly ended up using the same row.

Where this cam up was in the case of annotations where the generator is attached to a base entity class.

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Steve Ebersole added a comment - 29/Aug/08 09:49 AM
The setting to control this is 'prefer_entity_table_as_segment_value'

Drew Kutcharian added a comment - 13/Nov/08 02:52 AM
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

Drew Kutcharian added a comment - 13/Nov/08 11:27 AM
BTW, I'm using Hibernate 3.3.1.GA with Hibernate Annotations 3.4.0.GA

Steve Ebersole added a comment - 14/Nov/08 08:39 AM
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

Drew Kutcharian added a comment - 14/Nov/08 11:10 AM
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