-->
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: Discriminator in "Table per Hierarchy"
PostPosted: Mon Nov 14, 2005 11:52 am 
Newbie

Joined: Thu Oct 28, 2004 1:58 am
Posts: 10
Location: Pune,India.
How can I map discriminator and property to same database column?

eg.
@Entity
@Table(name = "PARAMETERS")
@Inheritance(
strategy = InheritanceType.SINGLE_TABLE,
discriminatorType=DiscriminatorType.INTEGER,
discriminatorValue = "0"
)
@DiscriminatorColumn(name = "PARAMETER_TYPE")
@Proxy(lazy = false)
class Param {

@Column(name = "PARAMETER_TYPE")
ParameterType type; //ParameteType is enum
}



class ConstantParam extends Param {
Constant cons;
}

class OtherParam extends Param {
Integer other;
}

In above example, i want to map discriminator and property to same column. I am not getting, how can i do this using annotation?
I know, using mapping we can do this by specifying "insert=false" in <discriminator>.

Thanks in advance,
Arpit


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 2:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Column(name = "PARAMETER_TYPE", insertable=false, updatable=false)
ParameterType type; //ParameteType is enum
}

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 1:28 am 
Newbie

Joined: Thu Oct 28, 2004 1:58 am
Posts: 10
Location: Pune,India.
emmanuel wrote:
@Column(name = "PARAMETER_TYPE", insertable=false, updatable=false)
ParameterType type; //ParameteType is enum
}


Thanks!!
It worked for me!!
I was little bit confused as in mapping file we specify insert=false in <discriminator> but here we specify "insertable=false" in column.


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.