Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA (TopLink) DB2 table generation

 
Morten Franorge
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When I use mye JPA Entities to generate tables in DB2, I get an error "-540". This error occurs because:

"THE DEFINITION OF TABLE <table name> IS INCOMPLETE BECAUSE IT LACKS A PRIMARY INDEX OR A REQUIRED UNIQUE INDEX"

The work around has been to create a unique index after the table is created:
CREATE UNIQUE INDEX tablename_PKEY
ON tablename
(
ID asc
)

When I've done this, I get another strange error stating that the index parameter is out of range, when calling entityManager.find(1, EntityClass.class)

I'm not sure whether it's a problem with TopLink's way of executing DDLs on db2 or what. Maybe there is a trick to get this working?
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Morten,

I know that one of the DB's they test with is Derby, which is similar to DB2 but I don't know if there are any issues with ddl gen on DB2 specifically. You might get a better response on the Glassfish forum. You can talk to the developers, there, and see if there is any existing known issue in the issue tracker.

-Mike
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your class have an Id mapping? Maybe that is what it was looking for and your object doesn't have one.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic