-->
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.  [ 1 post ] 
Author Message
 Post subject: Discriminator Value in an aggregated object
PostPosted: Fri Nov 27, 2009 3:42 pm 
Newbie

Joined: Fri Nov 27, 2009 3:25 pm
Posts: 1
Hi,

I have a question regarding a descriminator column values

My situation:
I have an main class A which contains an aggregated object of class B. Both classes contain an object identifier attribute which is used to uniquely identify the objects. Now I want to use a discriminator value/column from class B rather than from class A as I do not want to hold the TYPE (in addition to the b OID) in object A.

My question:
The following code snippet does not work as the TYPE column has to be in Class A to work. I'm wondering if it is possible to use e.g. a DiscriminatorFormular to reference a column from B to determine the discriminator value.
Also I know it would be possible to hold the TYPE column in A and B however this would mean the value is redundant in A (i want to avoid this situation).

Code:
@Entity
@Table(name="A")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(
   name="TYPE",
   discriminatorType=DiscriminatorType.STRING
)
@ForceDiscriminator
public class A {
   @ManyToOne(
      fetch=FetchType.EAGER,
      targetEntity=IssueTypeImpl.class,
      cascade = {CascadeType.PERSIST, CascadeType.MERGE})
   @JoinColumn(name="B_OID", nullable=false)
   private B b;
...
}

@Entity
@Table(name="B")
public class B {
   @Id
   @Column(name="OID", unique=true, nullable=false, length=64)
   private String oid;

   @Column(name="TYPE", nullable=false, length=40)
   private String type;

...
}




Thanks & Best Regards,
Walter


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.