I have a maven enabled project imported into Eclipse. From Eclipse, I get an error "No generator named "system-uuid" is defined in the persistence unit" on the system-uuid portion of the following lines:
@Id @GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@Column(length = 36)
public String getId() {
return id;
}
The project builds correctly from the command line. What is causing Eclipse to generate this error and how do I fix it?
The persistence file looks like this..
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="xxxx"/>
</persistence>
You can turn the error off/down under Preferences -> Java Persistence -> JPA -> Errors/Warnings under 'Queries and Generators' by changing the error 'Generator is not defined in the persistence unit' to a warning.
This looks like a bug in the Hibernate Tools extension of Dali in Eclipse.You could report this to Hibernate Tools or maybe this is fixed in a more recent version.
Eclipse Luna: This seems to work
Project -> Clean
Newer versions of Eclipse' JPA support seem to depend on the order of Annotations. You are defining the generator after you try to use em.
This will work:
@Id
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@GeneratedValue(generator = "system-uuid")
@Column(length = 36)
public String getId() {
return id;
}
However the order of annotations in Java must not have a meaning. So Karen is right, it seems to be a bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With