Results 1 to 2 of 2
  1. #1
    JackJoaquin is offline Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Default Hibernate inheritance:Table per class hierarchy

    Hello,

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

    Java 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` (`idUtente`);
    How do I create a hierarchy in the mapping of Hibernate with Netbeans?

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,776
    Rep Power
    5

    Default Re: Hibernate inheritance:Table per class hierarchy

    What does the Hibernate documentation tell you?

    Documentation - Hibernate - JBoss Community
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Inheritance hierarchy question
    By IAmACodingNoob in forum New To Java
    Replies: 3
    Last Post: 04-06-2012, 12:55 AM
  2. Help with inheritance/hierarchy
    By klz215 in forum New To Java
    Replies: 2
    Last Post: 02-23-2012, 08:42 PM
  3. Replies: 6
    Last Post: 07-04-2010, 04:01 PM
  4. help with inheritance in hibernate
    By valery in forum JDBC
    Replies: 1
    Last Post: 08-06-2007, 08:44 PM
  5. Hibernate table not found
    By orchid in forum JDBC
    Replies: 2
    Last Post: 05-06-2007, 07:44 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •