-->
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.  [ 4 posts ] 
Author Message
 Post subject: Override JoinTable
PostPosted: Thu Jun 22, 2006 6:15 am 
Beginner
Beginner

Joined: Sat Apr 15, 2006 12:49 pm
Posts: 20
Location: austria
Hi,

I'm wondering if there is a possibilty to override a JoinTable definition comming from a @MappedSuperclass in a way such that I can use different JoinTables for all classes extending the MappedSuperclass (similar to AttributeOverride).

Example:
Code:
@MappedSuperclass
public class SomeSuperClass {
    private List entries = new ArrayList();

   @OneToMany(targetEntity=Entry.class, fetch=FetchType.LAZY)
   @JoinTable(name="tblSuper2Entries", joinColumns={@JoinColumn(name="super_fk")}, inverseJoinColumns={@JoinColumn(name="entry_fk")})
   public List getEntries() {
      return this.entries;
   }
}



Then in some extending classes I would like to use the OneToMany association comming from "SomeSuperClass" with the only difference that I want to use different join tables for each sub-class. Therefore I'm looking for some annotation that allows me to rename the table "tblSuper2Entries" to a name unique for each sub-class.

Is there a way to realise this?

Thanks,

john


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 10:41 am 
Newbie

Joined: Thu Jun 22, 2006 5:19 pm
Posts: 8
Does redefining the method in the subclass work? i.e.
Code:
@Entity
public class SomeSubclass extends SomeSuperClass {
   @OneToMany(targetEntity=Entry.class, fetch=FetchType.LAZY)
   @JoinTable(name="tblSubEntries", joinColumns={@JoinColumn(name="super_fk")}, inverseJoinColumns={@JoinColumn(name="entry_fk")})
   public List getEntries() {
      return super.getEntries();
   }
}

_________________
John Dillenburg
University of Illinois at Chicago
Department of Computer Science


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 8:59 am 
Beginner
Beginner

Joined: Sat Apr 15, 2006 12:49 pm
Posts: 20
Location: austria
Not really, leads to the following error:

Code:
org.hibernate.DuplicateMappingException: Duplicate collection role mapping var.SomeSubClass.entries


Any other possibility?

thx,

john


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 9:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you have to mark the super method as @Transient.
Not sure it works though

_________________
Emmanuel


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