users@glassfish.java.net

Re: Sanity check: does _at_TableGenerator need to "come before" _at_GeneratedValue?

From: Mitesh Meswani <mitesh.meswani_at_oracle.com>
Date: Fri, 02 Sep 2011 15:59:30 -0700

The order is definitely not mandated. I am not able to spot anything
else wrong with the snippet you posted either. Post the stack trace in
server.log that corresponds to this error and the code snippet below to
EclipseLink user's forum.

On 9/2/2011 3:14 PM, Laird Nelson wrote:
> We're getting some odd deployment errors after introducing a cartload
> of @TableGenerator annotations on our entities.
>
> Here's a snippet:
>
> C:\glassfish3\bin>asadmin deploy C:\foo-ear-1.0-SNAPSHOT.ear
> remote failure: Error occurred during deployment: Exception while
> preparing the
> app : Unknown Id.generator: State. Please see server.log for more details.
> Command deploy failed.
>
> The class that this error is most likely talking about is annotated
> like this:
>
> @javax.xml.bind.annotation.XmlElement(name = "id")
> private long id;
>
> @javax.persistence.Access(javax.persistence.AccessType.PROPERTY)
> @javax.persistence.Column(name = "id")
> @javax.persistence.GeneratedValue(strategy =
> javax.persistence.GenerationType.TABLE, generator = "State")
> @javax.persistence.Id <http://javax.persistence.Id>
> @javax.persistence.TableGenerator(
> allocationSize = 500,
> initialValue = 100000,
> name = "State",
> pkColumnName = "sequence_name",
> pkColumnValue = "State",
> table = "jpa_sequence",
> valueColumnName = "last_value"
> )
> @Override
> protected long getId() {
> return this.id <http://this.id>;
> }
>
> find/grep yields no other generator named "State", and no other
> @GeneratedValue annotation referencing a generator of name "State".
>
> My first thought is this is (incredulously) order-related. Before I
> go and waste some time on slapping test cases together and other
> things that don't add value for our customers :-), I was hoping that
> someone right away could say oh, yep, order is important in these
> annotations, or, no, the problem is definitely going to be something else.
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>