-->
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: Can proxied objects be refreshed?
PostPosted: Thu Nov 20, 2003 3:53 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 6:15 am
Posts: 22
Hi all

I have a persistent object called AssetImpl that is proxied by the interface AssetORInterface. The part of the mapping file that declares the AssetImpl looks like this:

<hibernate-mapping>
<class
name="db.AssetImpl"
table="ASSET"
proxy="db.AssetORInterface"
dynamic-update="false"
dynamic-insert="false"
>

Interface AssetORInterface is a subinterface of Asset. The 3 Java files therefore look like:

public class AssetImpl implements AssetORInterface

public interface AssetORInterface extends Asset

public interface Asset extends java.io.Serializable

Then, I do the following:

Asset asset = session.load(AssetImpl.class, new Long(100));
session.refresh(asset);

and I got this exception:

java.lang.ClassCastException: java.lang.Object$$EnhancedByCGLIB$$0
at db.AssetImplMetaClass35.getPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:179)
at net.sf.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1930)
at net.sf.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1902)
at com.acme.DBHelper.getAsset(Unknown Source)

What did I do wrong? I need to refresh my asset after a load because we have mixed (JDBC & Hibernate) access to the asset table. I need to be sure that session.load() does not return a cached asset that has been modified somewhere else.

Could someone help me with this? Thank you very much.

Regards
Kevin


Top
 Profile  
 
 Post subject: Re: Can proxied objects be refreshed?
PostPosted: Thu Nov 20, 2003 3:56 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 6:15 am
Posts: 22
I missed out one bit, there is a typecast, of course:

Asset asset = (Asset)session.load(AssetImpl.class, new Long(100));
session.refresh(asset);

I'm certain the ClassCastException is not because of this typecast because without the refresh() call my code works fine.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 4:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
What version of Hibernate?

Try 2.1.


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.