-->
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: Polymorphic serialization not allowed?
PostPosted: Mon Nov 15, 2004 10:29 am 
Beginner
Beginner

Joined: Tue Aug 10, 2004 8:59 am
Posts: 47
Hibernate version:2.1

I have a class called PropertyRight which has a property called "modifyValidator". This property is supposed to store a serialized Java object of type Validator. Validator is an interface, and I have a huge number of classes which implement Validator. Hibernate accepts my mapping file in which I have specified the property as

<property name="modifyValidator" type="serializable">
<column name="MODIFY_VALIDATOR"/>
</property>

I can create an instance of PropertyRight, set its validator to be an instance of StringNotEmptyOrNullValidator (a type of Validator) and store it in the datbase, however, when I load the PropertyRight back in I get the exception below stating that it is an error to store a subtype of Validator in a column ment to store instances of Validator. This surprises me, because naturally I would expect Hibernate to support polymorphic serialization.

Has anyone got a clue to why this happens?

Randahl


15:13:45,765 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: dk.rockit.puls.server.entity.security.right.PropertyRight, setter method of property: modifyValidator
15:13:45,765 ERROR [BasicPropertyAccessor] expected type: dk.rockit.puls.omnipresent.validator.Validator, actual value: dk.rockit.puls.omnipresent.validator.string.StringNotEmptyOrNullValidator

[Note to the reader:] StringNotEmptyOrNullValidator is a class which implements the interface Validator


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.