-->
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: @MappedSuperclass in the middle of an inheritance hierarchy
PostPosted: Fri Aug 08, 2008 3:15 pm 
Newbie

Joined: Wed Dec 21, 2005 12:44 pm
Posts: 6
Hi, all,

I'm having some issues with declaring a mapped superclass in the middle of an EJB3 inheritance hierarchy. According to the documentation at http://www.hibernate.org/hib_docs/annot ... tml#d0e901 this should be possible, but I can't seem to get it to work. Here's my situation:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class SubscriptionTransaction {...}

@Entity
public abstract class CreditCardTransaction extends SubscriptionTransaction{...}

@MappedSuperclass
public abstract class VoidableTransaction extends CreditCardTransaction{
@OneToOne(mappedBy="voidableTransaction")
private VoidTransaction voidTransaction;
...
}

@Entity public class AuthTransaction extends VoidableTransaction {...}
@Entity public class CaptureTransaction extends VoidableTransaction {...}
@Entity public class CreditTransaction extends VoidableTransaction {...}

@Entity public class VoidTransaction extends CreditCardTransaction {
@OneToOne(optional = false)
private VoidableTransaction voidableTransaction;
...
}

Essentially, I want each of the voidable transaction type tables to have a void_transaction_id (which may be null). I don't want to add complexity to the joins by making VoidableTransaction a separate entity (and thus adding a table) entirely.

The problem that I'm running into is that when I run hbm2ddl on these classes, void_transaction_id is missing entirely from the relevant subclass tables. I have a couple of other classes annotated with @MappedSuperclass in the project that are at the root of the inheritance hierarchy, and their properties get inherited just fine, so I assume that it must be something else I'm doing wrong. Does anyone have any suggestions?

Thanks very much,

Kris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 11, 2008 1:36 pm 
Newbie

Joined: Wed Dec 21, 2005 12:44 pm
Posts: 6
I think I've figured out my issue here - it makes sense that Hibernate only needs to create a column for the voidable transaction id in the void_transaction table because it can enforce the one-to-one relationship with a unique constraint on that end rather than having bidirectional foreign keys. So my voidable_transaction class is only specifying behavior for the subclasses, which I guess is appropriate, and Hibernate will populate the inverse relationship just like it would populate a collection in a OneToMany relationship.


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.