-->
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.  [ 3 posts ] 
Author Message
 Post subject: How can I exclude certain records from being objects?
PostPosted: Wed Jul 30, 2008 3:06 pm 
Newbie

Joined: Wed Jul 30, 2008 1:54 pm
Posts: 11
I am using the 3.2.6 release of Hibernate Core, the 3.3.2 release of the EntityManager, and the 3.3.1 release of Annotations.

I have an interesting problem with mapping several objects with single table inheritance:

I have the following objects:

Code:
@Entity
@Table(name=”TEST_TABLE”)
@DiscriminatorColumn(name=”COL_1”)
public abstract class ParentObject
{
   @Id
   @Column(name="COL_2")
   private String code = null;
   
   @Column(name="COL_3")
   private String name = null;
   
   .....
}

@Entity
@DiscriminatorValue(value="13")
public class ChildObject
extends ParentObject
{
   @Column(name="COL_4")
   private String extraInfo = null;
   
   .....
}



This works very well, except for one problem: In some cases the "code" value in TEST_TABLE is blank (not null, just a blank string). In those cases, I don't want them to be considered valid ChildObjects and I need a way to discriminate against them.

Can somebody suggest a way that I can do that? I've looked at DiscriminatorFormula, but I can't find enough examples to understand how it might help me.

I'm very willing to go a little outside the box with this and use hibernate propriatary extensions, and the like.

Thank you so much.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 4:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Seems you found the solution yourself :)
http://forum.hibernate.org/viewtopic.php?p=2391699.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 8:46 pm 
Newbie

Joined: Wed Jul 30, 2008 1:54 pm
Posts: 11
I did! Thank you for linking it for me. I had forgotten!


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