-->
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.  [ 9 posts ] 
Author Message
 Post subject: mappedBy and InheritanceType.JOINED problem
PostPosted: Wed Dec 13, 2006 5:38 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
I am having a problem upgrading to JBoss 4.0.5. Please see the following post on the JBoss EJB3 forum.

http://www.jboss.org/index.html?module=bb&op=viewtopic&t=97260

Any assistance would be greatly appreciated.

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 9:09 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi Jason,

I don't think the null pointer exception (in fromClause.java) is caused Hibernate 3.2.0.GA that ships along with JBoss 4.0.5GA. To get it to work it will require you to manually patch the fromClause.java (very simple patch, only 1 or 2 lines). There is a bug in the Hibernate JIRA (http://opensource.atlassian.com/projects/hibernate/browse/HHH-2159), if you want it fixing (officially), please vote for the issue.

Cheers,


Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 11:36 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
My real problem is the mappedBy pointing to a property that is on a superclass of my object.

I am using a joined inheritance strategy.

Is there any reason I should not be able to map a collection to property of a superclass? This worked fine in 4.0.4.

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 17, 2006 6:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
if the superclass is an @Entity or a @Mappedsuperclass, it should work (unless you're not explaining all the details)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Have the same issue with Joined subclass
PostPosted: Thu Jan 11, 2007 5:43 pm 
Newbie

Joined: Wed Oct 11, 2006 3:48 pm
Posts: 1
I have the same issue. I resolved it by changing the parent to a MappedSuperclass and copying all columns from the parent table into each of the child tables.

When the superclass was using the joined inheiritance strategy, and I was trying to map a collection of a subclass on a parent mapped by the superclass, I got an exception that the mappedBy property didn't exist on the subclass (just as described above).

So, it seems that currently you can't have a collection of subclasses on a parent where the parent is mapped by the superclass if you're using a joined inheiritance strategy? Is this limitation intentional or a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 1:15 pm 
Beginner
Beginner

Joined: Tue Nov 14, 2006 4:11 pm
Posts: 23
Emmanuel communicated the following to me, and I figured it made sense to post it here since it is directly relevant (hopefully he won't mind):
Quote:
I did not properly understood the forum case hence the "unless you're not explaining all the details" :-)
What you can do could be possible (need to be tested) if the superclass was mapped with @MappedSuperclass, because in this case the FK is held by the entity class. But in your case, the FK is held by the superclass table, so from the relational POV, you have an association between the associated entity and the superclass, which is not what is described in your one to many association. I thought a lot about supporting this kind of case, but right now, I think it would be a bad thing to support: I like the consistency between the object model and the relational one.

Personally, I naturally assumed that you could map a relationship to a subclass using mappedBy on a superclass, even if the superclass is an entity. At least that's more like the way OO inheritance behaves. I recall changing to MappedSuperclass has other effects (at least w/ pure JPA), such loss of ability to do polymorphic queries. IMHO, seems it would be better to make the decision to go with MappedSuperclass versus Entity based on that kind of concern, not how you've set up the inheritance hierarchy. I can relate to wanting to keep things consistent, it's just that it seems like it should work as a few of us expected--so it takes time to figure out why it doesn't and how to work around it.

Instead of using MappedSuperclass, I chose to leave the superclass as an entity, make the accessors in the superclass abstract, and implement them in the subclass. Seems a bit duplicative, but it works and retains the consistency Emmanuel likes.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 26, 2007 4:11 pm 
Beginner
Beginner

Joined: Tue Nov 14, 2006 4:11 pm
Posts: 23
Quote:
Seems a bit duplicative, but it works and retains the consistency Emmanuel likes.

I was a bit optimistic in my assessment that it worked. I actually ended up getting ClassCastException when Hibernate would confuse the subtypes. I wrote up more about the approaches I worked through at my blog:
http://clarkupdike.blogspot.com/2007/01/hibernate-mappedby-to-superclass.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 30, 2009 2:39 pm 
Beginner
Beginner

Joined: Thu Nov 16, 2006 11:34 am
Posts: 26
Location: Boston
I have the same problem. Here's an example. Exam has many ExamDetails.


@Entity
public class Exam {

@OneToMany(mappedBy="exam")
private ExamDetails details

}


@Entity
@DiscriminatorValue("details")
public class ExamDetails extends Details {

}

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
public class Details extends MasterDetails {

}



@MappedSuperclass
public class MasterDetails {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
private Exam exam;

//getters & setters

}


I get the following errir:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: exam


Was there a workaround for this problem, and why is it not intuitive to support this feature?


Top
 Profile  
 
 Post subject: Re: mappedBy and InheritanceType.JOINED problem
PostPosted: Thu Sep 24, 2009 5:38 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
I am having the same problem, as the last poster - is this by design or by accident?


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