-->
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.  [ 5 posts ] 
Author Message
 Post subject: @Index(-es) for @CollectionOfElements autogenerated table
PostPosted: Sat Apr 22, 2006 4:50 pm 
Newbie

Joined: Fri Apr 22, 2005 3:39 pm
Posts: 18
Hello!

Is there a way to create indexes on columns of a table which is created to store @CollectionOfElements?

My code is:

...
@CollectionOfElements(fetch = FetchType.EAGER)
@JoinTable(name = "TOKENS", joinColumns = @JoinColumn(name = "NODE_FK"))
@Column(name = "TOKEN")
@IndexColumn(name = "POSITION")
public List<String> getTokens() {
return tokens;
}
...

After automatic schema createion for postgresql dialect I have a table:
CREATE TABLE path_token
(
node_fk int8 NOT NULL,
token varchar(255),
"position" int4 NOT NULL,
CONSTRAINT path_token_pkey PRIMARY KEY (node_fk, "position"),
CONSTRAINT fk99d8113f4c4aa404 FOREIGN KEY (node_fk) REFERENCES tree_node (id) ON UPDATE NO ACTION ON DELETE NO ACTION
)

Everything is nice and works but I want to add 3 indexes : for t every column of this table. Is there a way to do it with annotations? Any workarounds?

Thanks for any help!!!
Michael


Hibernate version:
1.3/annotations 1.3beta8


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 22, 2006 5:01 pm 
Newbie

Joined: Fri Apr 22, 2005 3:39 pm
Posts: 18
Hmm...

One more strange thing: the name of the table itself is not the one I provide with the annotations, but rather the autogenerated name.

Annotations reference has an example:
@JoinTable(
table=@Table(name="BoyFavoriteNumbers"),
joinColumns = @JoinColumn(name="BoyId")
)
which should in theory change the generated table name, but in my 3.1beta8 @JoinColumn annotation does NOT have the table property at all! Well, and it looks like the name (of the table?) property is also ignored...

Any ideas on this? Actually I'm more interested in getting the indexes generated, but having the table name OK would also be fine :-)

Thanks!!!
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 10:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you'll have to set the index manually, using an hbm database-object for example.

I can't reproduce the table name issue, are you sure of it?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 12:45 pm 
Newbie

Joined: Fri Apr 22, 2005 3:39 pm
Posts: 18
Hello!

I have switched to 3.2 CR and the table name issue seems to be gone. I'm not sure if it is gone because of the update or something else: my domain objects are under heavy development and I can't correlate it for sure.

Actually, would not it be nice to have a way to set the indexes using annotations? I like and heavily use the schema autogeneration feature.

Thanks for your work, and your answer!
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 12:09 am 
Newbie

Joined: Tue May 16, 2006 8:54 pm
Posts: 5
emmanuel wrote:
you'll have to set the index manually, using an hbm database-object for example.


Is there still no way to index a @CollectionOfElements field via annotations (As of Mar, 2007)? If not, how can this be done via database-object? The docs seem to only talk about customizing higher level things like create and drop statements.


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