Eclipse: No generator named "system-uuid" is defined in the persistence unit
Asked Answered
A

4

15

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>
Antonio answered 17/9, 2012 at 18:23 Comment(0)
S
42

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.

Shy answered 18/9, 2012 at 1:27 Comment(5)
But if the developers put this error to be checked, I'd stop to consider that we should do something in persistence.xml, don't you think so? :SConstruct
This answer seems quite old. I've just downloaded Eclipse luna and the problem is still there. I can't believe a bug would be live for such a long time. Is this really a bug on Dali?Schleswigholstein
This worked for me. However, I must agree with @IgnacioRubio. This suppresses the error and let's us proceed... however, why is the error being thrown in the first place? I have not found the solution based on my research.Oraorabel
2018 and its still persists! Eclipse Java EE IDE for Web Developers - 2018-09. I suggest to make changes to project specific settings. Under 'Errors/Warnings' click 'Configure Project Specific Settings' option and update.Gerta
Still up and not running in 2019, LOLDally
N
7

Eclipse Luna: This seems to work

Project -> Clean
Nuncle answered 31/5, 2017 at 11:25 Comment(0)
S
6

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.

Sherikasherill answered 5/8, 2015 at 8:51 Comment(1)
Didn't work for me either in any order. And Project > Clean... (suggested below) didn't help in either order. I'm using Mars.2 (4.5.2).Afflux
Y
0

I had almost same error - I used my custom id generator - in eclipse mars after importing my project from github.

the error : No generator named “idGenEchantillon” is defined in the persistence unit

So my answer is not really for the main question, but for other developers having same error as mine which can see here.

the code :

@Id
@GenericGenerator(name = "idGenEchantillon", strategy = "com.labo.model.KeyGenaratorForEchantillon")
@GeneratedValue(generator ="idGenEchantillon")
@Column(name = "ID_ECHANTILLON", length = 12)
private String idEchantillon;

I used maven to manage dependencies.

  1. I've removed the JPA facet from my project => every time I update my prject using Maven, the project take the JPA facet again => the error stay.
  2. I've disabled "JPA Configurator" option of Maven : Window >> Preferences >> Maven >> Java EE Integration , then uncheck "JPA CONFIGURATOR", after that I've update my project using Maven => the error is gone.
Yellowgreen answered 12/1, 2017 at 9:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.