Hibernate Tools generates @SequenceGenerator with not unique name

Description

When generating entities with EJB3 annotations with a strategy set to "sequence", Hibernate tools generates POJOs with non unique javax.persistence.SequenceGenerator name "generator". But according to the Java documentation :
String name (Required) A unique generator name that can be referenced by one or more classes to be the generator for primary key values.
See javadoc
Exemple of generated code with 4.0.0 Alpha1:
@SequenceGenerator(name = "generator", sequenceName = "S_CLIENT")
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "generator")
@Column(name = "CLIENT_ID", unique = true, nullable = false, precision = 22, scale = 0)
public long getClientId() {
return this.clientId;
}
Source code can be seen here.
So looks like the //TODO comment is right and it should generate a unique name atribute. sequencename+"generator" would be a good name.
It would even be better if we could define this name in reveng.xml or/and in a DelegatingReverseEngineeringStrategy class.

Environment

None

Activity

Show:

Koen Aers May 27, 2016 at 5:18 AM

This issue is solved but I created another one (HBX-1264) to make the name configurable and offer the possibility to have the @SequenceGenerator generated in a specially dedicated class file to make it reusable across entities.

Koen Aers May 24, 2016 at 1:26 PM

This issue duplicates JBIDE-12637 (https://issues.jboss.org/browse/JBIDE-12637).

Fixed

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Koen Aers

Priority

Created May 24, 2016 at 1:24 PM
Updated December 3, 2024 at 10:27 AM
Resolved May 27, 2016 at 5:18 AM