-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibenrate is adding Foreign Keys
PostPosted: Sat Jun 27, 2009 8:49 am 
Newbie

Joined: Fri Jun 26, 2009 7:31 pm
Posts: 5
Hi everybody,

I am using Hibernate synchronizer to do my final studies' project, but i'am facing a problem
I explain : I have a database composed of tables having (inheritance and composition) in some cases.. I've done the .hbm.xml mapping correctly.. but when i make a query on those tables from my java code (Eclipse), I realise that new Foreign Keys have been created in my table, even if I make (select queries) which make impossible for me to do further treatments on my table..

Before :
Code:
CREATE TABLE `feature` (
  `ID_ART` bigint(20) NOT NULL,
  `FEA_ID_ART` bigint(20) default NULL,
  `ID_PROD` bigint(20) default NULL,
  `NOM_ART` varchar(20) default NULL,
  `VER_ART` longtext,
  `STATUT_ART` longtext,
  `DESCRIPTION_ART` text,
  `PRIORITE_FEAT` varchar(10) default NULL,
  `DETAILS_FEAT` text,
  PRIMARY KEY  (`ID_ART`),
  KEY `COMPOSE_FEAT_FK` (`FEA_ID_ART`),
  CONSTRAINT `FK_COMPOSE_FEAT` FOREIGN KEY (`FEA_ID_ART`) REFERENCES `feature` (`ID_ART`),
  CONSTRAINT `FK_HERITAGE_1` FOREIGN KEY (`ID_ART`) REFERENCES `artifact` (`ID_ART`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


After :

Code:
CREATE TABLE `feature` (
  `ID_ART` bigint(20) NOT NULL,
  `FEA_ID_ART` bigint(20) default NULL,
  `ID_PROD` bigint(20) default NULL,
  `NOM_ART` varchar(20) default NULL,
  `VER_ART` longtext,
  `STATUT_ART` longtext,
  `DESCRIPTION_ART` text,
  `PRIORITE_FEAT` varchar(10) default NULL,
  `DETAILS_FEAT` text,
  PRIMARY KEY  (`ID_ART`),
  KEY `COMPOSE_FEAT_FK` (`FEA_ID_ART`),
  KEY `FKC5A27AF69E837999` (`ID_ART`),
  KEY `FKC5A27AF65060162D` (`ID_ART`),
  KEY `FKC5A27AF6708854F6` (`FEA_ID_ART`),
  CONSTRAINT `FKC5A27AF6708854F6` FOREIGN KEY (`FEA_ID_ART`) REFERENCES `feature` (`ID_ART`),
  CONSTRAINT `FKC5A27AF65060162D` FOREIGN KEY (`ID_ART`) REFERENCES `artifact` (`ID_ART`),
  CONSTRAINT `FKC5A27AF69E837999` FOREIGN KEY (`ID_ART`) REFERENCES `feature` (`ID_ART`),
  CONSTRAINT `FK_COMPOSE_FEAT` FOREIGN KEY (`FEA_ID_ART`) REFERENCES `feature` (`ID_ART`),
  CONSTRAINT `FK_HERITAGE_1` FOREIGN KEY (`ID_ART`) REFERENCES `artifact` (`ID_ART`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



As you can see, new FK are created (with the numbers) in my table, it makes me unable to make other queries (especially inserting)..

Im a working with Hibernate Synchronizer and a MySQL 5.0 database

I'm sorry for my weak English..

Thanks in advance for your help


Top
 Profile  
 
 Post subject: Re: Hibenrate is adding Foreign Keys
PostPosted: Mon Jun 29, 2009 11:11 am 
Newbie

Joined: Fri Jun 26, 2009 7:31 pm
Posts: 5
Hi everybody,

The problem was due to the hibernate.cfg.xml file

You need to erase this line : <property name="hbm2ddl.auto">update</property> to avoid regenerating the same DDL code each time you connect to the database

Hope it helps ;)


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

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.