-->
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: Discriminator with class name value
PostPosted: Tue Oct 24, 2006 7:20 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
Hibernate version:
3.1.3

Mapping documents:
Code:
<class name="com.example.Foo" table="foo">
   <id name="id" column="id"><generator class="native"/></id>

   <discriminator column="type" />

   <subclass discriminator-value="com.example.FooImplSimple"
                            name="com.example.FooImplSimple" />

   <subclass discriminator-value="com.example.FooImplComplex"
                            name="com.example.FooImplComplex" />
</class>


Hello

I have a database table called 'foo' with fields id (int) and type (varchar).
The contents of the table are:
1 - com.example.FooImplSimple
2 - com.example.FooImplComplex

Is there a way to improve the mapping by not having to explicitly bind each string discriminator value with the name of the class? The classname is the value of the field itself.

Thanks,
Ioannis


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 8:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the class name is the default value for the discriminator so just don't specify it.

WARNING: using the full classname is not without problems...think through what happens the day you decide to refactor your classes and move them into different packages!

_________________
Max
Don't forget to rate


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.