openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Goodenough <>
Subject Re: Please make Exceptions more useful...
Date Wed, 02 Apr 2008 14:59:41 GMT
On Wednesday 02 April 2008, David Goodenough wrote:
> I just got an error message which said:-
> Exception in thread "main" <openjpa-1.0.2-r420667:627158 nonfatal general
> error> org.apache.openjpa.persistence.PersistenceException: java.util.Date
> cannot be cast to java.util.Collection
> In this (and the accompanying stack trace) there is no indication which
> Date object cannot be cast to a Collection.  Yes from the stack trace I
> know that I was trying to persist a particular root object, but I have no
> idea which class and field this error refers to.  Simply adding the class
> and field would make debugging so much easier.
> Then once I know which Date field it might be, I can start to try to work
> out why it wanted to cast it to a collection.  Presumably this was it was
> trying to map this to a particular table, or to a set of objects of a given
> type, and again it would be useful to know what application object as
> opposed to raw java class it was trying to map to.
> David

Well I dug a little further into this one, and I am confused.  It does indeed
have a Date object that is it trying to cast as a Collection.

From the FieldMapping object current at the time when it fails the field
in question is, and its definition is:-

	@OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL) private List<Role> 

Which is (quite properly) a Collection, and is not a date (yes I know, I 
should not be using CascadeType.ALL, but at least here is does include
PERSIST.  As it happens this list is empty.

There is a Date, but it is in a superclass, its my @Version.  The superclass
is declared:-

@MappedSuperclass public class Basic extends Observed {
	@Version @Temporal(TemporalType.TIMESTAMP) private Date version;

and there is the version field as well.  The outer class is declared:-

@Entity @Table(name="Roles") public class Role extends Basic {

All of which looks right to my untrained eye.  My guess is that for some 
reason the system is getting confused about which class it is looking at,
the outer one or the super class but I do not know.  I have tried clearing
the binaries out from the Eclipse project, and rebuilding everything, but
that did not help.

Is this a known problem (in which case is there a workaround), if not 
what do you need to help track it down.


View raw message