Don't worry about his warning, just put the following in your log file and you shouldn't see it anymore:
Code:
<!-- This overcomes the proxy narrow log of hibernate -->
<logger name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
<level value="error" />
</logger>
Why it happens?
Suppose you have a Product with a many-to-one association to Address. Both are entities and Address has a ShippingAddress subclass.
Let's Session.get(..) a Product from the db that has ShippingAddress as association. Because the many-to-one is lazy, it will return a Address proxy. Note that this is a Address proxy and not a ShippingAddress proxy as the proxy will always match the type that is mentioned in Product (see the hibernate book for details).
This proxy is stored by Hibernate in his proxy cache.
Now we Session.get(...) the same ShippingAddress from the db, the one that is associated to the Product that we used fetched from the db.
Now Hibernate will see that it already contains a proxy for this ShippingAddress and will return this. However, it will notice that the types aren't the same so a "downcasting" must occur. Because this latter action isn't possible with "proxies" it will create new one and return it...
As you can see, nothing to worry about.
You could consider making the Address a value type...
In my case that's no option.
Hope this helps,
Ed Bras