[nbusers] Detail Table with composite primary key

  • From: Sasha Shams < >
  • To:
  • Subject: [nbusers] Detail Table with composite primary key
  • Date: Thu, 29 Mar 2012 21:24:03 -0700 (PDT)

I am working on a project with MySQL database Java GUI.

This is my SQL script CREATE TABLE takenservice ( ResvID INT UNSIGNED NOT
NULL, ServID INT UNSIGNED DEFAULT 0 NOT NULL, ServUsedDate DATETIME NOT NULL
, PayStat VARCHAR(6) DEFAULT Unpaid NOT NULL, ServRecBy VARCHAR(7) NOT NULL,
PayRecBy VARCHAR(7), Quantity SMALLINT DEFAULT 1 NOT NULL, PRIMARY KEY
(ResvID, ServID, ServUsedDate)); Alter table takenservice add constraint
foreign key (ResvId) references reservation (ResvID); Alter table
takenservice add constraint foreign key (ResvId) references reservation
(ResvID);

I created the entity classes with Netbeans 7.0 and created 4 classes:

Service Reservation ServiceTaken ServiceTakenPK

but I cant enter values to the table and it gives me an error that I am
trying to enter null values in as primary keys.

I have found the bug actually in Netbeans forum which is
http://netbeans.org/bugzilla/show_bug.cgi?id=105084.

and accordingly I have added the following methods to the class ServiceTaken

public int getResvID() {
    return takenservicePK.resvID;
}

public int getServID() {
    return takenservicePK.servID;
}

public Date getServUsedDate() {
    return takenservicePK.servUsedDate;
upon inserting a new entry in the table I get this error :

Error Code: 1048 Call: INSERT INTO takenservice (PayRecBy, ServRecBy,
Quantity, PayStat, ServUsedDate, ResvID, ServID) VALUES (?, ?, ?, ?, ?, ?,
?) bind => [ddd, ddd, 0, ddd, null, null, null]

What I can do to fix this ? Please help me with this I am running out of
time =/

--
View this message in context: 
http://netbeans-org.1045718.n5.nabble.com/Detail-Table-with-composite-primary-key-tp5605659p5605659.html
Sent from the Netbeans IDE Users mailing list archive at Nabble.com.


[nbusers] Detail Table with composite primary key

Sasha Shams 03/30/2012

<Possible follow-up(s)>

[nbusers] Detail Table with composite primary key

Sasha Shams 03/30/2012

[nbusers] Re: Detail Table with composite primary key

Javier Ortiz 03/30/2012

[nbusers] Re: Detail Table with composite primary key

Salwa H. Shams 03/30/2012

[nbusers] Re: Detail Table with composite primary key

Javier Ortiz 03/30/2012

[nbusers] Re: Detail Table with composite primary key

Salwa H. Shams 03/31/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close