-->
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.  [ 3 posts ] 
Author Message
 Post subject: SchemaUpdate creates duplicate indexes
PostPosted: Mon Nov 07, 2005 2:38 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
With "hibernate.hbm2ddl.auto" set to update, schemaUpdate creates indexes even though they already exists in the [mysql] db.

indexes on client before:

mysql> show index from client;
+--------+------------+---------------+--------------+---------------+-----------+-------------+----------+--------+----
--+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Nul
l | Index_type | Comment |
+--------+------------+---------------+--------------+---------------+-----------+-------------+----------+--------+----
--+------------+---------+
| client | 0 | PRIMARY | 1 | clientId | A | 0 | NULL | NULL |
| BTREE | |
| client | 1 | hostreftypeId | 1 | hostreftypeId | A | 0 | NULL | NULL |
| BTREE | |
| client | 1 | ugroupId | 1 | ugroupId | A | 0 | NULL | NULL | YES
| BTREE | |
+--------+------------+---------------+--------------+---------------+-----------+-------------+----------+--------+----
--+------------+---------+
3 rows in set (0.13 sec)

indexes on client after:

mysql> show index from client;
+--------+------------+--------------------+--------------+---------------+-----------+-------------+-------
+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_pa
| Null | Index_type | Comment |
+--------+------------+--------------------+--------------+---------------+-----------+-------------+-------
+------+------------+---------+
| client | 0 | PRIMARY | 1 | clientId | A | 0 | NU
| | BTREE | |
| client | 1 | hostreftypeId | 1 | hostreftypeId | A | 0 | NU
| | BTREE | |
| client | 1 | ugroupId | 1 | ugroupId | A | 0 | NU
| YES | BTREE | |
| client | 1 | FKAF12F3CB8B66DDE5 | 1 | ugroupId | A | 0 | NU
| YES | BTREE | |
| client | 1 | FKAF12F3CBB22057A0 | 1 | hostreftypeId | A | 0 | NU
| | BTREE | |
+--------+------------+--------------------+--------------+---------------+-----------+-------------+-------

Anyone know why this occurs or how I can get Configuration.generateSchemaUpdateScript to reconnize the existing indexes?

Thanks, jeff

Hibernate version: 2.1.8 (30.1.2005)

Name and version of the database you are using: mySQL: 4.1,
jdbc Driver: mysql-connector-java-3.1.11-bin.jar

Debug level Hibernate log excerpt:
2005-11-07 13:21:46,699 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <Running hbm2ddl schema update>
2005-11-07 13:21:46,699 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <fetching database metadata>
2005-11-07 13:21:46,879 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <updating schema>
2005-11-07 13:21:47,520 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table threshold add column penaltyreftypeId integer>
2005-11-07 13:21:48,041 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table client add column localIpAddress varchar(15)>
2005-11-07 13:21:48,332 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table group_hostreftype add column groupId integer>
2005-11-07 13:21:48,602 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table policy add index FKC56DA532F44F8356 (policyreftypeId), add constraint FKC56DA532F44F8356 foreign key (policyreftypeId) references policyreftype (policyreftypeId)>
2005-11-07 13:21:48,852 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table logmessage_throwable add index FKB9AD0444625EB7F (logId), add constraint FKB9AD0444625EB7F foreign key (logId) references logmessage (logId)>
2005-11-07 13:21:49,103 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table policyassessment add index FK9B61857436253646 (clientId), add constraint FK9B61857436253646 foreign key (clientId) references client (clientId)>
2005-11-07 13:21:49,293 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table policyassessment add index FK9B61857432FA7EE6 (thresholdId), add constraint FK9B61857432FA7EE6 foreign key (thresholdId) references threshold (thresholdId)>
2005-11-07 13:21:49,483 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table policyassessment add index FK9B61857420BA36B3 (prevThresholdId), add constraint FK9B61857420BA36B3 foreign key (prevThresholdId) references threshold (thresholdId)>
2005-11-07 13:21:49,703 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table policyassessment add index FK9B6185741BB19361 (enforcePriorityId), add constraint FK9B6185741BB19361 foreign key (enforcePriorityId) references enforcepriority (enforcePriorityId)>
2005-11-07 13:21:49,954 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table threshold add index FKA3E1E46B1BB19361 (enforcePriorityId), add constraint FKA3E1E46B1BB19361 foreign key (enforcePriorityId) references enforcepriority (enforcePriorityId)>
2005-11-07 13:21:50,214 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table authhist add index FK5567A8CA36253646 (clientId), add constraint FK5567A8CA36253646 foreign key (clientId) references client (clientId)>
2005-11-07 13:21:50,425 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table client add index FKAF12F3CB8B66DDE5 (ugroupId), add constraint FKAF12F3CB8B66DDE5 foreign key (ugroupId) references ugroup (ugroupId)>
2005-11-07 13:21:50,645 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table client add index FKAF12F3CBB22057A0 (hostreftypeId), add constraint FKAF12F3CBB22057A0 foreign key (hostreftypeId) references hostreftype (hostreftypeId)>
2005-11-07 13:21:50,915 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table leaveactions add index FK9B224E6632FA7EE6 (thresholdId), add constraint FK9B224E6632FA7EE6 foreign key (thresholdId) references threshold (thresholdId)>
2005-11-07 13:21:51,156 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table leaveactions add index FK9B224E669D48D1F1 (actionId), add constraint FK9B224E669D48D1F1 foreign key (actionId) references action (actionId)>
2005-11-07 13:21:51,386 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table group_hostreftype add index FKA24731E5B22057A0 (hostreftypeId), add constraint FKA24731E5B22057A0 foreign key (hostreftypeId) references hostreftype (hostreftypeId)>
2005-11-07 13:21:51,606 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table group_hostreftype add index FKA24731E58B66DDE5 (ugroupId), add constraint FKA24731E58B66DDE5 foreign key (ugroupId) references ugroup (ugroupId)>
2005-11-07 13:21:51,857 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table group_hostreftype add index FKA24731E5117D5BFA (groupId), add constraint FKA24731E5117D5BFA foreign key (groupId) references ugroup (ugroupId)>
2005-11-07 13:21:52,067 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <Unsuccessful: alter table group_hostreftype add index FKA24731E5117D5BFA (groupId), add constraint FKA24731E5117D5BFA foreign key (groupId) references ugroup (ugroupId)>
2005-11-07 13:21:52,067 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <General error, message from server: "Can't create table '.\nap\#sql-66c_bd.frm' (errno: 150)">
2005-11-07 13:21:52,067 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table enforcepriority add index FKDEDF7786209929ED (policyId), add constraint FKDEDF7786209929ED foreign key (policyId) references policy (policyId)>
2005-11-07 13:21:52,337 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table enforcepriority add index FKDEDF77868B66DDE5 (ugroupId), add constraint FKDEDF77868B66DDE5 foreign key (ugroupId) references ugroup (ugroupId)>
2005-11-07 13:21:52,558 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table correctivestep add index FKC9905FFA209929ED (policyId), add constraint FKC9905FFA209929ED foreign key (policyId) references policy (policyId)>
2005-11-07 13:21:52,788 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table bandwidth add index FK8AD4C0B136253646 (clientId), add constraint FK8AD4C0B136253646 foreign key (clientId) references client (clientId)>
2005-11-07 13:21:53,088 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table useragent add index FK1452FE1AB22057A0 (hostreftypeId), add constraint FK1452FE1AB22057A0 foreign key (hostreftypeId) references hostreftype (hostreftypeId)>
2005-11-07 13:21:53,319 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table enteractions add index FK30A85F259D48D1F1 (actionId), add constraint FK30A85F259D48D1F1 foreign key (actionId) references action (actionId)>
2005-11-07 13:21:53,539 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table enteractions add index FK30A85F2532FA7EE6 (thresholdId), add constraint FK30A85F2532FA7EE6 foreign key (thresholdId) references threshold (thresholdId)>
2005-11-07 13:21:53,759 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table networksession add index FKAD8BF8A836253646 (clientId), add constraint FKAD8BF8A836253646 foreign key (clientId) references client (clientId)>
2005-11-07 13:21:54,010 DEBUG [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <alter table ipdefinition add index FKF743DBA8B66DDE5 (ugroupId), add constraint FKF743DBA8B66DDE5 foreign key (ugroupId) references ugroup (ugroupId)>
2005-11-07 13:21:54,260 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute] - - <schema update complete>

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.impulse.business.domain.enforce.ClientImpl"
table="client"
>
<meta attribute="implement-equals" inherit="false">true</meta>

<id name="clientId"
type="int"
column="clientId"
unsaved-value="0"
>
<generator class="identity" />
</id>

<!--
<version column="Version" name="version" type="int" />
-->

<!-- Begin audit fields -->
<property name="createDate"
type="java.sql.Timestamp"
column="createDate"
>
</property>

<property name="createUser"
type="java.lang.String"
column="CreateUser"
>
</property>

<property name="lstUpdDate"
type="java.sql.Timestamp"
column="lstUpdDate"
>
</property>

<property name="lstUpdUser"
type="java.lang.String"
column="lstUpdUser"
>
</property>
<!-- End audit fields -->

<property name="sessionUid"
type="java.lang.String"
column="sessionUID"
not-null="true"
length="32"
>
</property>
<property name="macaddress"
type="java.lang.String"
column="macaddress"

length="25"
>
</property>
<property name="formerIpAddress"
type="java.lang.String"
column="formerIpAddress"
length="15"
>
</property>
<property name="currentIpAddress"
type="java.lang.String"
column="currentIpAddress"
length="15"
>
</property>
<property name="localIpAddress"
type="java.lang.String"
column="localIpAddress"
length="15"
>
</property>
<property name="lastContactTime"
type="java.lang.Integer"
column="lastContactTime"
not-null="true"
length="11"
>
</property>
<property name="expirationTime"
type="java.lang.Integer"
column="expirationTime"
not-null="true"
length="11"
>
</property>

<property name="userLoginName"
type="java.lang.String"
column="userLoginName"
>
</property>

<property name="winMachineName"
type="java.lang.String"
column="winMachineName"
>
</property>

<property
name="groupUpdated"
type="java.lang.Boolean"
column="groupUpdated"
/>

<property
name="quarantined"
type="java.lang.Boolean"
column="quarantined"
/>
<property
name="ilan"
type="java.lang.Boolean"
column="ilan"
/>

<!-- Associations -->

<!-- bi-directional many-to-one association to Hostreftype -->
<many-to-one
name="hostType"
class="com.impulse.business.domain.enforce.HostTypeImpl"
not-null="true"
>
<column name="hostreftypeId" />
</many-to-one>

<!-- bi-directional one-to-many association to policyAssessments -->
<set
name="policyAssessments"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="com.impulse.business.domain.comparator.PolicyComplianceComparator"
>
<key>
<column name="clientId" />
</key>
<one-to-many
class="com.impulse.business.domain.enforce.PolicyAssessmentImpl"
/>
</set>

<!-- bi-directional one-to-many association to NetworkSessionImpl -->
<set
name="networkSessions"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
>
<key>
<column name="clientId" />
</key>
<one-to-many
class="com.impulse.business.domain.enforce.NetworkSessionImpl"
/>
</set>

<!-- bi-directional one-to-many association to BandwidthImpl -->
<set
name="bandwidth"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
>
<key>
<column name="clientId" />
</key>
<one-to-many
class="com.impulse.business.domain.enforce.BandwidthImpl"
/>
</set>

<!-- bi-directional one-to-many association to AuthenticationHistoryImpl -->
<set
name="authenticationHistory"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
order-by = "authHistId asc"
>
<key>
<column name="clientId" />
</key>
<one-to-many
class="com.impulse.business.domain.enforce.AuthenticationHistoryImpl"
/>
</set>

<!-- bi-directional many-to-one association to Group -->
<many-to-one name="group"
class="com.impulse.business.domain.enforce.GroupImpl"

column="ugroupId" />


</class>
</hibernate-mapping>


Client table DDL:

CREATE TABLE client (
clientId mediumint(9) unsigned NOT NULL auto_increment,
PRIMARY KEY (clientId),
sessionUID varchar(32) NOT NULL default '',
macaddress varchar(25) ,
formerIpAddress varchar(15) NULL ,
currentIpAddress varchar(15) NULL ,
lastContactTime int(11) unsigned NOT NULL default '0',
expirationTime int(11) unsigned NOT NULL default '0',
userLoginName varchar(45),
winMachineName varchar(45),
groupUpdated tinyint(1) NOT NULL default '0',
quarantined tinyint(1) NOT NULL default '0',
ilan tinyint(1) NOT NULL default '0',

-- AUDIT FIELDS --
version int(11) NOT NULL default '0',
createDate timestamp NOT NULL ,
createUser varchar(45),
lstUpdDate timestamp NOT NULL ,
lstUpdUser varchar(45) ,

-- FK'S --
hostreftypeId mediumint(9) unsigned NOT NULL default '0',
ugroupId mediumint(9) unsigned NULL ,

-- HOSTREFTYPE --
INDEX hostreftypeId (hostreftypeId),
CONSTRAINT `client_ibfk_1` FOREIGN KEY (`hostreftypeId`) REFERENCES `hostreftype` (`hostreftypeId`),

-- UGROUP --
INDEX ugroupId (ugroupId),
CONSTRAINT `client_ibfk_2` FOREIGN KEY (`ugroupId`) REFERENCES `ugroup` (`ugroupId`)

) TYPE=InnoDB;


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 4:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
maybe a bug - go look in the source and see if it is ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: SchemaUpdate creates duplicate indexes
PostPosted: Sun Jun 28, 2009 2:13 pm 
Newbie

Joined: Mon Aug 07, 2006 1:02 am
Posts: 2
Location: Houston, TX
I am having the same issue with hibernate 3.3 and mysql 5.1 ... is there a workaround for this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.