-->
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: Single table inheritance with subclass @ManyToMany mapping
PostPosted: Tue Jul 21, 2009 7:08 am 
Newbie

Joined: Fri Jan 30, 2009 4:58 pm
Posts: 6
I have an application which persists report parameters. Reports are mapped through a single table hierarchy (a wide table, but with relatively few rows). Problems arise when the same @ManyToMany mapping is used in multiple report subclasses. In this cases Hibernate schema export will generate multiple constraints for the same foreign key. This results in an error on Oracle, not allowing multiple constraints for the same foreign key.

The example below manifests the problem. Here two constraints will be generated on the table Report_TestEntity for the attribute report_id. (The same happens if I explicitly set the foreign key name through the @ForeignKey annotation.)

Does anyone know how to solve this problem?

Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@AccessType("field")
public class Report {
    @Id private Long id;
}

@Entity
public class XReport extends Report {
    @ManyToMany private List<TestEntity> testEntity = new ArrayList<TestEntity>();
}

@Entity
public class YReport extends Report {
    @ManyToMany private List<TestEntity> testEntity = new ArrayList<TestEntity>();
}

@Entity
@AccessType("field")
public class TestEntity {
    @Id private Long id;
}


Top
 Profile  
 
 Post subject: Re: Single table inheritance with subclass @ManyToMany mapping
PostPosted: Thu Jul 23, 2009 4:29 am 
Newbie

Joined: Fri Jan 30, 2009 4:58 pm
Posts: 6
The same problem occurs if I have the same @CollectionOfElements mapping in multiple subclasses of the base class.


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.