Skip to main content

Table 'SEQUENCE' does not exist.

7 replies [Last post]
cayhorstmann
Offline
Joined: 2003-06-13

I am trying to persist a simple entity bean:

@Entity
public class User implements Serializable
{
private String name;
private int id;

@Id(generate = GeneratorType.AUTO)
public int getId () {
return id;
}

public void setId (int id) {
this.id = id;
}

public String getName() { return name; }
public void setName(String name) { this.name = name; }
}

My persistence.xml is this, taken from the example at http://blogs.sun.com/roller/page/pavel?entry=java_ee_5_persistence_crud

<?xml version="1.0" encoding="UTF-8"?>

jdbc/__default

GlassFish build 28 gives this error:

Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 10g release 4 (10.1.4.0.0) (Build 051115Dev)): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.apache.derby.client.am.SqlException: Table 'SEQUENCE' does not exist.Error Code: -1
Call:UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + 50 WHERE SEQ_NAME = 'SEQ_GEN'

Was I supposed to create this table???

Thanks,

Cay

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cayhorstmann
Offline
Joined: 2003-06-13

On December 1, 2005, mm110099 wrote:
---------------
For now, you will need to manually create the table and also insert a seed row into it as follows

CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50), SEQ_COUNT DECIMAL(15));
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)

Very soon the schema generation feature will be available which will take care of above for you.
---------------

I just tried a simple JPA client (not an appclient), and I still got a failure because no sequence table is generated.

Is that a bug, or was "very soon" overly optimistic?

Thanks,

Cay

zambizzi
Offline
Joined: 2005-08-19

Is there a patch or something for this yet? I use Postgres and this is a bit of a pain.

I'm using b48.

ss141213
Offline
Joined: 2005-03-30

Sorry, I don't see what's the issue here. I am [b]able[/b] to get my app working with [b]GenerationType=AUTO[/b] . I am using Derby which uses SEQUENCE table for AUTO generation strategy.

Note that, if SEQUENCE table does [b]not[/b] exist, [b]don't always expect[/b] a persistence provider to create SEQUENCE table for you automatically unless you use [b]Java2DB[/b] (a.k.a. automatic table generation strategy) feature. The persistence spec is quite clear in section #9.1.9:
[i]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.[/i]

So, bottom line is, there is no bug here; it can be an enhancement. At the moment, [b]either create the resource by hand or turn on Java2db[/b]. There are various ways to turn on this feature as discussed in http://blogs.sun.com/roller/page/java2dbInGlassFish?entry=automatic_tabl...

Thanks,
Sahoo

zambizzi
Offline
Joined: 2005-08-19

Problem solved - thanks Sahoo.

mm110999
Offline
Joined: 2005-03-29

For now, you will need to manually create the table and also insert a seed row into it as follows

CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50), SEQ_COUNT DECIMAL(15))
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)

Very soon the schema generation feature will be available which will take care of above for you

cayhorstmann
Offline
Joined: 2003-06-13

Thank you for the information.

I looked into the sample code of

http://java.sun.com/developer/EJTechTips/2005/tt1122.html#2

and they use the database URL

jdbc:derby://localhost:1527/sun-appserv-samples;create=true;user=APP;password=APP

Is that the right place to put the tables?

Thanks,

Cay

mvatkina
Offline
Joined: 2005-04-04

GeneratorType.AUTO is not yet supported without having an extra table.

regards,
-marina