-->
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: adding an index to the discriminator column
PostPosted: Tue Dec 18, 2007 2:20 pm 
Newbie

Joined: Mon Oct 08, 2007 6:55 pm
Posts: 2
Location: california
Hello,

I have a hibernate setup with 50+ objects. For some tables I have multiple objects in the same table, hence I use a 'discriminator' to distinguish the objects.

Now, how can I go about adding an index to the discriminator column?

I am using MySQL 5 with InnoDB tables.

I have tried...

@Entity
@Table(name="PersistObject",uniqueConstraints = @UniqueConstraint(columnNames = {"manufacturer", "partNumber"}))
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="type",
discriminatorType=DiscriminatorType.CHAR,
columnDefinition="CHAR(1) CHARACTER SET utf8 COLLATE utf8_bin"
)
@DiscriminatorValue("4")
@org.hibernate.annotations.Table(appliesTo = "PersistObject", indexes = @org.hibernate.annotations.Index(name = "type_index", columnNames = "type"))

to no avail. I have also tried editing the xml config but with no results.

Your input would be greatly appreciated.

Thanks,
Omid S

_________________
Thanks!, Omid S


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 9:46 pm 
Regular
Regular

Joined: Sat Nov 25, 2006 11:37 am
Posts: 72
Are you using Hibernate to create your schema SQL or are you connecting to an existing database. In the second case simply use the MySQL tools to create the index. Hibernate only need to know about the index if you want Hibernate to generate the schema SQL for you.


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.