-->
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: InvalidClassException with Hibernate 3.6.0 and JPA 2.0
PostPosted: Fri Nov 05, 2010 1:05 pm 
Newbie

Joined: Wed Nov 03, 2010 2:36 pm
Posts: 9
Hi,
I've just started using hibernate 3.6.0 and JPA 2.0 and I'm having some troubles.


I get InvalidClassException on some queries. By the way I'm using metamodel with hibernate-jpamodelgen.

I.e. one below runs fine:
Code:
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<UserEntity> cq = getCriteriaQuery(cb);
cq.where(cb.equal(cq.from(UserEntity.class).get(UserEntity_.username), username));


but with this one I'm having trouble:
Code:
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<UserGroup> cq = getCriteriaQuery(cb);

cq.where(cb.equal(cq.from(UserGroup.class).join(UserGroup_.entries).join(UserGroupEntry_.user).get(UserEntity_.id), user.getId()));


I get exception like below.
All classes used in query implements Serializable.

I'm kinda lost here so any help would be appreciated.

Code:
java.io.InvalidClassException: com.ptm.model.BaseEntity; local class incompatible: stream classdesc serialVersionUID = 7662749495871325837, local class serialVersionUID = 8176072949097236524
     at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:579)
     at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1600)
     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
     at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1600)
     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
     at org.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:244)
     at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:306)
     at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:130)
     at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:116)
     at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:39)
     at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:62)
     at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
     at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
     at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)


Top
 Profile  
 
 Post subject: Re: InvalidClassException with Hibernate 3.6.0 and JPA 2.0
PostPosted: Mon Nov 08, 2010 5:42 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Check your classpath. I bet you have your "com.ptm.model.BaseEntity" defined twice there (that is there are two JARs with different versions of your class).

Another reason could be the wrong visibility of "serialVersionUID" field, but I am not sure if it is possible at all.


Top
 Profile  
 
 Post subject: Re: InvalidClassException with Hibernate 3.6.0 and JPA 2.0
PostPosted: Mon Nov 08, 2010 5:56 am 
Newbie

Joined: Wed Nov 03, 2010 2:36 pm
Posts: 9
Well, that wasn't the case.
There were no other version of BaseEntity class - i triple checked and my classes don't even have "serialVersionUID" field defined, they only implement Serializable.
I was using older version of Hibernate and JPA 1.0 and then moved to Hibernate 3.6.0 and JPA 2.0. Some queries ran fine and some failed.
After I removed data from tables and inserted again via application - everything worked out. But I'm not sure why though :)


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.