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: Naming Constraints
PostPosted: Tue Jul 31, 2007 8:39 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Hi everybody,
am I correct in the assumption, that I cannot currently name the foreign_key on a mapkey_id?

For example I have this mapping

Code:
  @ManyToMany(cascade = CascadeType.ALL)
  @ForeignKey(name = "fk_role_privilege_role", inverseName = "fk_role_privilege_privilege")
  Map<Privilege, PrivilegeConstraint<?>> privs =
      new HashMap<Privilege, PrivilegeConstraint<?>>();


creating this table and foreign keys
Code:
  CREATE TABLE "RAIL"."AC_ROLE_PRIVILEGECONSTRAINT"
   (   "AC_ROLE_ID" NUMBER(19,0) NOT NULL ENABLE,
   "PRIVS_ID" NUMBER(19,0) NOT NULL ENABLE,
   "MAPKEY_ID" NUMBER(19,0) NOT NULL ENABLE,
    PRIMARY KEY ("AC_ROLE_ID", "MAPKEY_ID") ENABLE,
    CONSTRAINT "FKEC400F82AB02DCF8" FOREIGN KEY ("MAPKEY_ID")
     REFERENCES "RAIL"."AC_PRIVILEGE" ("ID") ENABLE,
    CONSTRAINT "FK_ROLE_PRIVILEGE_ROLE" FOREIGN KEY ("AC_ROLE_ID")
     REFERENCES "RAIL"."AC_ROLE" ("ID") ENABLE,
    CONSTRAINT "FK_ROLE_PRIVILEGE_PRIVILEGE" FOREIGN KEY ("PRIVS_ID")
     REFERENCES "RAIL"."PRIVILEGECONSTRAINT" ("ID") ENABLE
   ) ;


As one might imagine, I am not to happy about this foreign key name.
FKEC400F82AB02DCF8

Is there any way to change it in to something meaningfull?

kind regards
Jens


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 31, 2007 8:42 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Actually, same issue but different direction of thinking:

Is it possible to replace the naming strategy? Of course I guess we could track the responsible class down in the sourcecode and replace it. But I am thinking more along the lines of a configuration somewhere and an interface to implement.

Jens


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 01, 2007 2:49 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
And just another question about a similiar problem:

We are working with Oracle and at least with oracle it is normally advisable to put an index on a FK Column. For a Many to One relationship I can do that :-)
But what about ManyToMany relations?

In the example above: how do I create a index on privs_id and mapkey_id?


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.