-->
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: How to persist proxied (wrapped) object?
PostPosted: Thu Sep 09, 2004 5:12 pm 
Newbie

Joined: Sat Jun 19, 2004 7:08 am
Posts: 4
An usual domain model consisting of POJOs is mapped to be persisted with Hibernate (works ok).
I am using the Spring Framework AOP cappabilities - so my POJOs are proxied by Spring to add desired aspects.

For example, lets say that a class Product is mapped to be persisted with Hibernate. Then, in the Spring mapping files, it is defined to be intercepted in a way that every method is logged (maybe not the best example). In a runtime, every object that is obtained via Spring Bean Factory and manipulated in the program code behaves like it is a Product, but if you invoke getClass().getName() on it you will get something like $Proxy123.

The problem arises when I need to store (save, update, whatever) these proxied objects. Hibernate probably tries to determine the class name, so it tries to persist %Proxy123 instead of Product.

How can I tell Hibernate "that's a proxy that can't be stored but it can give you the right object if you ask", when it try to store (or do something else) my object?

Probably the solution is somewhere in net.sf.hibernate.Interceptor interface. Hibernate3 adds Interceptor.getEntityName() method that might be helpful (I am not sure), but Spring still does not support Hibernate3.

Anyone got the solution?


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.