As you may know from other posts I'm currently at the beginning of a
migration project from EJB 2.1 to EJB 3.0. So until recently we hadn't
much code to deploy. But as we had made some progress I wanted to
create a test deployment. Javac had compiled the code and some first
unit tests were all green. Everything OK? Wlappc didn't thought so.
Weblogics ejb compiler throw the following exception:
[wlappc]
<openjpa-1.1.0-r422266:657916 fatal user error>
org.apache.openjpa.util.MetaDataException: "….entity.Entity.id"
declares generator name "GUID_GEN", but uses the AUTO generation
type. The only valid generator names under AUTO are "uuid-hex"
and "uuid-string".
The field of the entity it complained about looked like this:
@Id
@GeneratedValue(generator=
"GUID_GEN")
@GenericGenerator(name="GUID_GEN",
strategy=”…..GUIDGen”)
private String id;
As you see the id is of type string. The old project used a custom id
generator that produced strings and we had to stick to it.
Looking at the javadoc of GeneratedValue
and GenerationType
didn't tell me much about the error message. Searching the net for the
message didn't help either. When asking the colleague that programmed
the class he told me in a site note that this is a mix of Hibernate and
JPA as pure JPA doesn't support custom id generators. GenericGenerator
is actually a hibernate class.
Searching on the net about custom id generators for JPA brought the
solution. You need to specify a strategy attribute for the
GeneratedValue annotation. The examples I've seen used SEQUENCE but
wlappc also accepted TABLE.