-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate inheritance
PostPosted: Fri Sep 06, 2013 5:27 am 
Newbie

Joined: Wed Jan 23, 2013 4:53 pm
Posts: 2
Hello,

I have 3 table in the db, and I am in a situation of hierarchy. I enclose the tables.

Code:
CREATE TABLE IF NOT EXISTS `utente` (
  `idUtente` int(11) NOT NULL AUTO_INCREMENT,
  `abilitato` enum('T','F') NOT NULL DEFAULT 'T',
  `cognome` varchar(50) DEFAULT NULL,
  `nome` varchar(50) DEFAULT NULL,
  `dataNascita` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `idComuneNascita` int(11) NOT NULL,
  `tel1` varchar(15) DEFAULT NULL,
  `tel2` varchar(15) DEFAULT NULL,
  `tel3` varchar(15) DEFAULT NULL,
  `fax` varchar(15) DEFAULT NULL,
  `email` varchar(50) DEFAULT NULL,
  `sito` varchar(100) DEFAULT NULL,
  `sesso` enum('M','F') DEFAULT NULL,
  `note` longtext,
  `idTipoSocieta` int(3) NOT NULL,
  `ragioneSociale` varchar(150) NOT NULL,
  `partitaIva` varchar(11) NOT NULL,
  `codiceFiscale` varchar(16) DEFAULT NULL,
  `idTipoPagamento` int(3) DEFAULT NULL,
  PRIMARY KEY (`idUtente`),
  UNIQUE KEY `ragioneSociale` (`ragioneSociale`,`partitaIva`),
  KEY `idComuneNascita` (`idComuneNascita`),
  KEY `idTipoSocieta` (`idTipoSocieta`),
  KEY `idTipoPagamento` (`idTipoPagamento`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

CREATE TABLE IF NOT EXISTS `cliente` (
  `codCliente` varchar(10) NOT NULL,
  `fido` decimal(7,2) DEFAULT NULL,
  `idPosizioneIva` int(11) NOT NULL,
  `id` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `codCliente` (`codCliente`,`id`),
  KEY `idPosizioneIva` (`idPosizioneIva`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `cliente`
  ADD CONSTRAINT `cliente_ibfk_6` FOREIGN KEY (`id`) REFERENCES `utente` (`idUtente`),
  ADD CONSTRAINT `cliente_ibfk_5` FOREIGN KEY (`idPosizioneIva`) REFERENCES `posizioneiva` (`id`);

CREATE TABLE IF NOT EXISTS `fornitore` (
  `id` int(11) NOT NULL,
  `codFornitore` varchar(10) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_codFornitore` (`id`,`codFornitore`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `fornitore`
  ADD CONSTRAINT `fornitore_ibfk_1` FOREIGN KEY (`id`) REFERENCES `utente


How do I create a hierarchy in the mapping of Hibernate with Netbeans?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.