Carlos Solorio created NETBEANS-1916:
----------------------------------------

             Summary: Entity Classes from DB: cannot generate from tables 
without primary keys
                 Key: NETBEANS-1916
                 URL: https://issues.apache.org/jira/browse/NETBEANS-1916
             Project: NetBeans
          Issue Type: Bug
          Components: javaee - Persistence
    Affects Versions: 9.0, 8.2, 10.0
         Environment: Windows 7 SP1 x64. 
            Reporter: Carlos Solorio
         Attachments: bugnb1.PNG

When Entity classes are attempted to be created from "Entity Classes from 
Database" wizard,  and a valid database connection is selected (in my case, 
MySQL), some tables cannot be selected due to "not having a primary key" even 
though it is there...

Below are all the associated tables with their corresponding DDL (genreated by 
MySQL Workbench). The table where no primary key is detected is 
"joint_orderentry".

CREATE TABLE `joint_orderentry` (
 `idjoint_orderentry` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
 `shared_amount` decimal(15,4) unsigned NOT NULL,
 `order_id` bigint(19) unsigned DEFAULT NULL,
 `user_id` bigint(19) unsigned DEFAULT NULL,
 PRIMARY KEY (`idjoint_orderentry`),
 UNIQUE KEY `idjoint_orderentry_UNIQUE` (`idjoint_orderentry`),
 KEY `fk_joint_order_idx` (`order_id`),
 KEY `fk_joint_user_idx` (`user_id`),
 CONSTRAINT `fk_joint_order` FOREIGN KEY (`order_id`) REFERENCES `buy_order` 
(`idorder`) ON DELETE SET NULL ON UPDATE CASCADE,
 CONSTRAINT `fk_joint_user` FOREIGN KEY (`user_id`) REFERENCES `user_` (`id`) 
ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_es_0900_as_cs

CREATE TABLE `buy_order` (
 `idorder` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
 `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `pay_time` timestamp NULL DEFAULT NULL,
 `received_time` timestamp NULL DEFAULT NULL,
 `total_amount` decimal(15,4) unsigned NOT NULL,
 `order_address` bigint(19) unsigned DEFAULT NULL,
 `shipment_amount` decimal(15,4) unsigned DEFAULT NULL,
 `status` varchar(45) COLLATE utf8mb4_es_0900_as_cs DEFAULT NULL,
 PRIMARY KEY (`idorder`),
 UNIQUE KEY `idorder_UNIQUE` (`idorder`),
 KEY `fk_order_address_idx` (`order_address`),
 CONSTRAINT `fk_order_address` FOREIGN KEY (`order_address`) REFERENCES 
`address` (`idaddress`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_es_0900_as_cs

CREATE TABLE `user_` (
 `ID` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
 `ACCOUNT_EXPIRED` tinyint(1) DEFAULT NULL,
 `ACCOUNT_LOCKED` tinyint(1) DEFAULT NULL,
 `ENABLED` tinyint(1) DEFAULT NULL,
 `CREDENTIALS_EXPIRED` tinyint(1) DEFAULT NULL,
 `PASSWORD` varchar(255) COLLATE utf8mb4_es_0900_as_cs DEFAULT NULL,
 `USER_NAME` varchar(255) COLLATE utf8mb4_es_0900_as_cs DEFAULT NULL,
 `role` int(10) unsigned DEFAULT NULL,
 PRIMARY KEY (`ID`),
 UNIQUE KEY `ID_UNIQUE` (`ID`),
 UNIQUE KEY `USER_USER_NAME` (`USER_NAME`),
 KEY `fk_user_role_idx` (`role`),
 CONSTRAINT `fk_user_role` FOREIGN KEY (`role`) REFERENCES `role` (`idrole`) ON 
DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_es_0900_as_cs

CREATE TABLE `payment` (
 `idpayment` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
 `method` varchar(20) COLLATE utf8mb4_es_0900_as_cs NOT NULL,
 `payment_order` bigint(19) unsigned DEFAULT NULL,
 PRIMARY KEY (`idpayment`),
 UNIQUE KEY `idpayment_UNIQUE` (`idpayment`),
 KEY `fk_payment_order_idx` (`payment_order`),
 CONSTRAINT `fk_payment_order` FOREIGN KEY (`payment_order`) REFERENCES 
`joint_orderentry` (`idjoint_orderentry`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_es_0900_as_cs

CREATE TABLE `role` (
 `idrole` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `role_name` varchar(20) COLLATE utf8mb4_es_0900_as_cs NOT NULL DEFAULT 
'END_USER',
 PRIMARY KEY (`idrole`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_es_0900_as_cs

All this follows the issue in  the previous issue tracking system: 
https://netbeans.org/bugzilla/show_bug.cgi?id=81716



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to