Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Sequence validator
Sequence validator [message #434625] Thu, 01 November 2007 00:13 Go to next message
Eclipse UserFriend
Originally posted by: erich.tierfour.com

All:

I was using Eclipse 3.2 with the webtools plugin and my project validated
and ran fine.

However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
and now I am having problems getting the JPA annotation validator to
validate my primary key generator names.

Example:

@Entity
@Table(name = "tblaccount")
public class AccountBean {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"tblaccount_accountid_seq")
@Column(name = "accountid")
//@GeneratedValue
private long accountId;

I get an error on the @GeneratedValue annotation:

'No generator named "tblaccount_accountid_seq" is defined in the
persistence unit'.

So, I searched for that error on google and found two references in the
Eclipse documentation for DALI. And I quote from the DALI manual:

Quoting from the manual under the Error messages section:


'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

You created a persistence entity that uses sequencing, but did not define
include the sequence generator in the psersistence.xml file. Synchronize
the persistence.xml file with your current project.

See "Synchronizing classes" for more information.'

That section tells you to synchronize persistence.xml, which does
absolutely nothing. There are no sequences added to that file (nor can I
find any documentation that suggests that they should be listed in the
file) and nothing else in the file is changed.

So, I started thinking that I have the wrong database driver (3.3 is after
all running Java6 by default) so I tried some different drivers, including
the JDBC4 driver, but still, It won't validate the sequence names, nor
will it compile the project.

For reference, I'm using PostgreSQL, I am connected to the database during
validation, and yes it does validate and compile under the previous
version of WTK.

Anyone have any ideas?
Re: Sequence validator [message #434626 is a reply to message #434625] Fri, 02 November 2007 13:55 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
It looks like you have found some problems with our documentation. As you
suspect, the generator doesn't have any direct relationship with the
persistence.xml or Synchronize Classes functionality.

The intent of this validation is to insure that a Generator is defined for
a given generator reference. In this case you are referencing the
generator "tblaccount_accountid_seq". Is this generator defined in your
persistence unit somewhere (via annotation or xml)? Dali is trying to
validate that the generator is defined, since if it is not, that would
normally be a problem.

Neil



Erich wrote:

> All:

> I was using Eclipse 3.2 with the webtools plugin and my project validated
> and ran fine.

> However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
> and now I am having problems getting the JPA annotation validator to
> validate my primary key generator names.

> Example:

> @Entity
> @Table(name = "tblaccount")
> public class AccountBean {
> @Id
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> "tblaccount_accountid_seq")
> @Column(name = "accountid")
> //@GeneratedValue
> private long accountId;

> I get an error on the @GeneratedValue annotation:

> 'No generator named "tblaccount_accountid_seq" is defined in the
> persistence unit'.

> So, I searched for that error on google and found two references in the
> Eclipse documentation for DALI. And I quote from the DALI manual:

> Quoting from the manual under the Error messages section:


> 'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

> You created a persistence entity that uses sequencing, but did not define
> include the sequence generator in the psersistence.xml file. Synchronize
> the persistence.xml file with your current project.

> See "Synchronizing classes" for more information.'

> That section tells you to synchronize persistence.xml, which does
> absolutely nothing. There are no sequences added to that file (nor can I
> find any documentation that suggests that they should be listed in the
> file) and nothing else in the file is changed.

> So, I started thinking that I have the wrong database driver (3.3 is after
> all running Java6 by default) so I tried some different drivers, including
> the JDBC4 driver, but still, It won't validate the sequence names, nor
> will it compile the project.

> For reference, I'm using PostgreSQL, I am connected to the database during
> validation, and yes it does validate and compile under the previous
> version of WTK.

> Anyone have any ideas?
Re: Sequence validator [message #434627 is a reply to message #434626] Sat, 03 November 2007 04:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: erich.tierfour.com

I'm sure that is the problem. I don't have it defined in XML or an
annotation. However, I haven't been able to find any documentation which
explains how to add the generator to the persistence unit via XML or to
the class with an annotation.

The reason I am so baffled is that the validation on 3.2-WTK works fine,
it's just europa with Web Tools 2 that seems to recognize that the
sequences are not defined and therefore complains about it. I assumed
that 3.2-WTK was validating directly against the schema, which is why I
tried different drivers to see if I could get it working again that way,
but I guess it really is supposed to be defined in XML or annotation
somehow and this must be a new feature of 2.0 - the ability to recognize
undefined sequences.

Can anyone point me somewhere where I may find some information regarding
defining sequences in XML or in annotation form? I've found plenty of
example code showing the use of the sequence (like my own), but I can't
find anywhere that shows how to define the sequence in xml or annotation.
I'd prefer annotation, but XML would be fine too. I just need to be able
to compile my code again.

Thanks!

Neil Hauge wrote:

> It looks like you have found some problems with our documentation. As you
> suspect, the generator doesn't have any direct relationship with the
> persistence.xml or Synchronize Classes functionality.

> The intent of this validation is to insure that a Generator is defined for
> a given generator reference. In this case you are referencing the
> generator "tblaccount_accountid_seq". Is this generator defined in your
> persistence unit somewhere (via annotation or xml)? Dali is trying to
> validate that the generator is defined, since if it is not, that would
> normally be a problem.

> Neil



> Erich wrote:

>> All:

>> I was using Eclipse 3.2 with the webtools plugin and my project validated
>> and ran fine.

>> However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
>> and now I am having problems getting the JPA annotation validator to
>> validate my primary key generator names.

>> Example:

>> @Entity
>> @Table(name = "tblaccount")
>> public class AccountBean {
>> @Id
>> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
>> "tblaccount_accountid_seq")
>> @Column(name = "accountid")
>> //@GeneratedValue
>> private long accountId;

>> I get an error on the @GeneratedValue annotation:

>> 'No generator named "tblaccount_accountid_seq" is defined in the
>> persistence unit'.

>> So, I searched for that error on google and found two references in the
>> Eclipse documentation for DALI. And I quote from the DALI manual:

>> Quoting from the manual under the Error messages section:


>> 'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

>> You created a persistence entity that uses sequencing, but did not define
>> include the sequence generator in the psersistence.xml file. Synchronize
>> the persistence.xml file with your current project.

>> See "Synchronizing classes" for more information.'

>> That section tells you to synchronize persistence.xml, which does
>> absolutely nothing. There are no sequences added to that file (nor can I
>> find any documentation that suggests that they should be listed in the
>> file) and nothing else in the file is changed.

>> So, I started thinking that I have the wrong database driver (3.3 is after
>> all running Java6 by default) so I tried some different drivers, including
>> the JDBC4 driver, but still, It won't validate the sequence names, nor
>> will it compile the project.

>> For reference, I'm using PostgreSQL, I am connected to the database during
>> validation, and yes it does validate and compile under the previous
>> version of WTK.

>> Anyone have any ideas?
Re: Sequence validator [message #434628 is a reply to message #434627] Mon, 05 November 2007 14:37 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
That's correct, we added this validation in WTP 2.0, so this is why it
didn't report the error before.

As for how do define them, here are the options:

by Annotation:

@SequenceGenerator(name="Foo_Generator", sequenceName="Foo_Seq")

This Annotation can be defined on the Id attribute, the class, or any
class. It is a global declaration, and can be referenced by any Entity in
the persistence unit.

Because of its global nature, it is considered a good practice to define
the Generator in XML if it is going to be referenced by multiple Entities,
but this is up to you.

by XML:
<entity-mappings>
<sequence-generator name="Foo_Generator", sequence-name="Foo_Seq")
<entity-mappings>

This should fix things up for you. I highly recommend the book "Pro EJB 3
- Java Persistence API" as a reference for these types of issues. It has
a lot of valuable information on JPA annotations and XML mapping, in
addition to general concepts and strategies.

Neil


Erich wrote:

> I'm sure that is the problem. I don't have it defined in XML or an
> annotation. However, I haven't been able to find any documentation which
> explains how to add the generator to the persistence unit via XML or to
> the class with an annotation.

> The reason I am so baffled is that the validation on 3.2-WTK works fine,
> it's just europa with Web Tools 2 that seems to recognize that the
> sequences are not defined and therefore complains about it. I assumed
> that 3.2-WTK was validating directly against the schema, which is why I
> tried different drivers to see if I could get it working again that way,
> but I guess it really is supposed to be defined in XML or annotation
> somehow and this must be a new feature of 2.0 - the ability to recognize
> undefined sequences.

> Can anyone point me somewhere where I may find some information regarding
> defining sequences in XML or in annotation form? I've found plenty of
> example code showing the use of the sequence (like my own), but I can't
> find anywhere that shows how to define the sequence in xml or annotation.
> I'd prefer annotation, but XML would be fine too. I just need to be able
> to compile my code again.

> Thanks!

> Neil Hauge wrote:

>> It looks like you have found some problems with our documentation. As you
>> suspect, the generator doesn't have any direct relationship with the
>> persistence.xml or Synchronize Classes functionality.

>> The intent of this validation is to insure that a Generator is defined for
>> a given generator reference. In this case you are referencing the
>> generator "tblaccount_accountid_seq". Is this generator defined in your
>> persistence unit somewhere (via annotation or xml)? Dali is trying to
>> validate that the generator is defined, since if it is not, that would
>> normally be a problem.

>> Neil



>> Erich wrote:

>>> All:

>>> I was using Eclipse 3.2 with the webtools plugin and my project validated
>>> and ran fine.

>>> However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
>>> and now I am having problems getting the JPA annotation validator to
>>> validate my primary key generator names.

>>> Example:

>>> @Entity
>>> @Table(name = "tblaccount")
>>> public class AccountBean {
>>> @Id
>>> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
>>> "tblaccount_accountid_seq")
>>> @Column(name = "accountid")
>>> //@GeneratedValue
>>> private long accountId;

>>> I get an error on the @GeneratedValue annotation:

>>> 'No generator named "tblaccount_accountid_seq" is defined in the
>>> persistence unit'.

>>> So, I searched for that error on google and found two references in the
>>> Eclipse documentation for DALI. And I quote from the DALI manual:

>>> Quoting from the manual under the Error messages section:


>>> 'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

>>> You created a persistence entity that uses sequencing, but did not define
>>> include the sequence generator in the psersistence.xml file. Synchronize
>>> the persistence.xml file with your current project.

>>> See "Synchronizing classes" for more information.'

>>> That section tells you to synchronize persistence.xml, which does
>>> absolutely nothing. There are no sequences added to that file (nor can I
>>> find any documentation that suggests that they should be listed in the
>>> file) and nothing else in the file is changed.

>>> So, I started thinking that I have the wrong database driver (3.3 is after
>>> all running Java6 by default) so I tried some different drivers, including
>>> the JDBC4 driver, but still, It won't validate the sequence names, nor
>>> will it compile the project.

>>> For reference, I'm using PostgreSQL, I am connected to the database during
>>> validation, and yes it does validate and compile under the previous
>>> version of WTK.

>>> Anyone have any ideas?
Re: Sequence validator [message #434629 is a reply to message #434628] Thu, 08 November 2007 08:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: erich.tierfour.com

Thanks. That was the annotation that I needed. It validates now.

Hopefully this thread will be indexed and someone else who has the same
problem as me will find your reply helpful to them.

It would also of course be nice if the documentation got fixed sometime.

Thanks,

Erich
Re: Sequence validator [message #434630 is a reply to message #434629] Mon, 12 November 2007 16:10 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
The issue can be tracked here -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=208574.

Neil
Re: Sequence validator [message #607401 is a reply to message #434625] Fri, 02 November 2007 13:55 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
It looks like you have found some problems with our documentation. As you
suspect, the generator doesn't have any direct relationship with the
persistence.xml or Synchronize Classes functionality.

The intent of this validation is to insure that a Generator is defined for
a given generator reference. In this case you are referencing the
generator "tblaccount_accountid_seq". Is this generator defined in your
persistence unit somewhere (via annotation or xml)? Dali is trying to
validate that the generator is defined, since if it is not, that would
normally be a problem.

Neil



Erich wrote:

> All:

> I was using Eclipse 3.2 with the webtools plugin and my project validated
> and ran fine.

> However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
> and now I am having problems getting the JPA annotation validator to
> validate my primary key generator names.

> Example:

> @Entity
> @Table(name = "tblaccount")
> public class AccountBean {
> @Id
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> "tblaccount_accountid_seq")
> @Column(name = "accountid")
> //@GeneratedValue
> private long accountId;

> I get an error on the @GeneratedValue annotation:

> 'No generator named "tblaccount_accountid_seq" is defined in the
> persistence unit'.

> So, I searched for that error on google and found two references in the
> Eclipse documentation for DALI. And I quote from the DALI manual:

> Quoting from the manual under the Error messages section:


> 'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

> You created a persistence entity that uses sequencing, but did not define
> include the sequence generator in the psersistence.xml file. Synchronize
> the persistence.xml file with your current project.

> See "Synchronizing classes" for more information.'

> That section tells you to synchronize persistence.xml, which does
> absolutely nothing. There are no sequences added to that file (nor can I
> find any documentation that suggests that they should be listed in the
> file) and nothing else in the file is changed.

> So, I started thinking that I have the wrong database driver (3.3 is after
> all running Java6 by default) so I tried some different drivers, including
> the JDBC4 driver, but still, It won't validate the sequence names, nor
> will it compile the project.

> For reference, I'm using PostgreSQL, I am connected to the database during
> validation, and yes it does validate and compile under the previous
> version of WTK.

> Anyone have any ideas?
Re: Sequence validator [message #607402 is a reply to message #434626] Sat, 03 November 2007 04:16 Go to previous message
Erich  is currently offline Erich Friend
Messages: 10
Registered: July 2010
Junior Member
I'm sure that is the problem. I don't have it defined in XML or an
annotation. However, I haven't been able to find any documentation which
explains how to add the generator to the persistence unit via XML or to
the class with an annotation.

The reason I am so baffled is that the validation on 3.2-WTK works fine,
it's just europa with Web Tools 2 that seems to recognize that the
sequences are not defined and therefore complains about it. I assumed
that 3.2-WTK was validating directly against the schema, which is why I
tried different drivers to see if I could get it working again that way,
but I guess it really is supposed to be defined in XML or annotation
somehow and this must be a new feature of 2.0 - the ability to recognize
undefined sequences.

Can anyone point me somewhere where I may find some information regarding
defining sequences in XML or in annotation form? I've found plenty of
example code showing the use of the sequence (like my own), but I can't
find anywhere that shows how to define the sequence in xml or annotation.
I'd prefer annotation, but XML would be fine too. I just need to be able
to compile my code again.

Thanks!

Neil Hauge wrote:

> It looks like you have found some problems with our documentation. As you
> suspect, the generator doesn't have any direct relationship with the
> persistence.xml or Synchronize Classes functionality.

> The intent of this validation is to insure that a Generator is defined for
> a given generator reference. In this case you are referencing the
> generator "tblaccount_accountid_seq". Is this generator defined in your
> persistence unit somewhere (via annotation or xml)? Dali is trying to
> validate that the generator is defined, since if it is not, that would
> normally be a problem.

> Neil



> Erich wrote:

>> All:

>> I was using Eclipse 3.2 with the webtools plugin and my project validated
>> and ran fine.

>> However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
>> and now I am having problems getting the JPA annotation validator to
>> validate my primary key generator names.

>> Example:

>> @Entity
>> @Table(name = "tblaccount")
>> public class AccountBean {
>> @Id
>> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
>> "tblaccount_accountid_seq")
>> @Column(name = "accountid")
>> //@GeneratedValue
>> private long accountId;

>> I get an error on the @GeneratedValue annotation:

>> 'No generator named "tblaccount_accountid_seq" is defined in the
>> persistence unit'.

>> So, I searched for that error on google and found two references in the
>> Eclipse documentation for DALI. And I quote from the DALI manual:

>> Quoting from the manual under the Error messages section:


>> 'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

>> You created a persistence entity that uses sequencing, but did not define
>> include the sequence generator in the psersistence.xml file. Synchronize
>> the persistence.xml file with your current project.

>> See "Synchronizing classes" for more information.'

>> That section tells you to synchronize persistence.xml, which does
>> absolutely nothing. There are no sequences added to that file (nor can I
>> find any documentation that suggests that they should be listed in the
>> file) and nothing else in the file is changed.

>> So, I started thinking that I have the wrong database driver (3.3 is after
>> all running Java6 by default) so I tried some different drivers, including
>> the JDBC4 driver, but still, It won't validate the sequence names, nor
>> will it compile the project.

>> For reference, I'm using PostgreSQL, I am connected to the database during
>> validation, and yes it does validate and compile under the previous
>> version of WTK.

>> Anyone have any ideas?
Re: Sequence validator [message #607403 is a reply to message #434627] Mon, 05 November 2007 14:37 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
That's correct, we added this validation in WTP 2.0, so this is why it
didn't report the error before.

As for how do define them, here are the options:

by Annotation:

@SequenceGenerator(name="Foo_Generator", sequenceName="Foo_Seq")

This Annotation can be defined on the Id attribute, the class, or any
class. It is a global declaration, and can be referenced by any Entity in
the persistence unit.

Because of its global nature, it is considered a good practice to define
the Generator in XML if it is going to be referenced by multiple Entities,
but this is up to you.

by XML:
<entity-mappings>
<sequence-generator name="Foo_Generator", sequence-name="Foo_Seq")
<entity-mappings>

This should fix things up for you. I highly recommend the book "Pro EJB 3
- Java Persistence API" as a reference for these types of issues. It has
a lot of valuable information on JPA annotations and XML mapping, in
addition to general concepts and strategies.

Neil


Erich wrote:

> I'm sure that is the problem. I don't have it defined in XML or an
> annotation. However, I haven't been able to find any documentation which
> explains how to add the generator to the persistence unit via XML or to
> the class with an annotation.

> The reason I am so baffled is that the validation on 3.2-WTK works fine,
> it's just europa with Web Tools 2 that seems to recognize that the
> sequences are not defined and therefore complains about it. I assumed
> that 3.2-WTK was validating directly against the schema, which is why I
> tried different drivers to see if I could get it working again that way,
> but I guess it really is supposed to be defined in XML or annotation
> somehow and this must be a new feature of 2.0 - the ability to recognize
> undefined sequences.

> Can anyone point me somewhere where I may find some information regarding
> defining sequences in XML or in annotation form? I've found plenty of
> example code showing the use of the sequence (like my own), but I can't
> find anywhere that shows how to define the sequence in xml or annotation.
> I'd prefer annotation, but XML would be fine too. I just need to be able
> to compile my code again.

> Thanks!

> Neil Hauge wrote:

>> It looks like you have found some problems with our documentation. As you
>> suspect, the generator doesn't have any direct relationship with the
>> persistence.xml or Synchronize Classes functionality.

>> The intent of this validation is to insure that a Generator is defined for
>> a given generator reference. In this case you are referencing the
>> generator "tblaccount_accountid_seq". Is this generator defined in your
>> persistence unit somewhere (via annotation or xml)? Dali is trying to
>> validate that the generator is defined, since if it is not, that would
>> normally be a problem.

>> Neil



>> Erich wrote:

>>> All:

>>> I was using Eclipse 3.2 with the webtools plugin and my project validated
>>> and ran fine.

>>> However, I just upgraded to Eclipse 3.3 europa with the webtools plugin,
>>> and now I am having problems getting the JPA annotation validator to
>>> validate my primary key generator names.

>>> Example:

>>> @Entity
>>> @Table(name = "tblaccount")
>>> public class AccountBean {
>>> @Id
>>> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
>>> "tblaccount_accountid_seq")
>>> @Column(name = "accountid")
>>> //@GeneratedValue
>>> private long accountId;

>>> I get an error on the @GeneratedValue annotation:

>>> 'No generator named "tblaccount_accountid_seq" is defined in the
>>> persistence unit'.

>>> So, I searched for that error on google and found two references in the
>>> Eclipse documentation for DALI. And I quote from the DALI manual:

>>> Quoting from the manual under the Error messages section:


>>> 'No generator named "<GENERATOR_NAME>" is defined in persistence unit.

>>> You created a persistence entity that uses sequencing, but did not define
>>> include the sequence generator in the psersistence.xml file. Synchronize
>>> the persistence.xml file with your current project.

>>> See "Synchronizing classes" for more information.'

>>> That section tells you to synchronize persistence.xml, which does
>>> absolutely nothing. There are no sequences added to that file (nor can I
>>> find any documentation that suggests that they should be listed in the
>>> file) and nothing else in the file is changed.

>>> So, I started thinking that I have the wrong database driver (3.3 is after
>>> all running Java6 by default) so I tried some different drivers, including
>>> the JDBC4 driver, but still, It won't validate the sequence names, nor
>>> will it compile the project.

>>> For reference, I'm using PostgreSQL, I am connected to the database during
>>> validation, and yes it does validate and compile under the previous
>>> version of WTK.

>>> Anyone have any ideas?
Re: Sequence validator [message #607404 is a reply to message #434628] Thu, 08 November 2007 08:27 Go to previous message
Erich  is currently offline Erich Friend
Messages: 10
Registered: July 2010
Junior Member
Thanks. That was the annotation that I needed. It validates now.

Hopefully this thread will be indexed and someone else who has the same
problem as me will find your reply helpful to them.

It would also of course be nice if the documentation got fixed sometime.

Thanks,

Erich
Re: Sequence validator [message #607405 is a reply to message #434629] Mon, 12 November 2007 16:10 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
The issue can be tracked here -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=208574

Neil
Previous Topic:Integrating EJB 3.0 (Hibernate) into Eclipse
Next Topic:Problems with Dali 1.0
Goto Forum:
  


Current Time: Thu Apr 18 14:33:38 GMT 2024

Powered by FUDForum. Page generated in 0.02497 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top