On Sat, Jan 24, 2009 at 2:02 AM, Martin Uhlir <stoupa91de...@seznam.cz> wrote:

> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
> relation "country" does not exist {prepstmnt 16963612 INSERT INTO Country
> (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0,
> state=42P01]
...
> What does this '.....relation "country" does not exist".....' mean? I'm just
> using this simple entity bean which I try to persist in a stateless session
> bean.
> @Entity
> public class Country {
>   private Long id;
>   private String name;
>
>   public void setId(Long id) {
>       this.id = id;
>   }
>
>   @Id
>   public Long getId() {
>       return id;
>   }

How do you work with the entity? Why was the id 5 in the exception if
it had never worked before? Did PostgreSQL assign 5 from the very
begining? You didn't set the id yourself, did you? Show the relevant
session ejb snippet where the entity is used.

I also wonder if no @GeneratedValue with @Id causes the exception.
9.1.9 GeneratedValue Annotation in the EJB 3.0 spec reads (AUTO is the
default value):

The AUTO value indicates that the persistence provider should pick an
appropriate strategy for the particular database. The AUTO generation
strategy may expect a database resource to exist, or it may attempt to
create one. A vendor may provide documentation on how to create such
resources in the event that it does not support schema generation or
cannot create the schema resource at runtime.

That's why the exception contained reference to "relation country",
but it still doesn't sound good.

BTW, you don't have to use the wrapper classes, e.g. Long for entity
fields - primitive types work fine, e.g. long.

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl

Reply via email to